packngo

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: BSD-3-Clause, MIT Imports: 15 Imported by: 288

README

packngo

Packet Go Api Client

Installation

go get github.com/packethost/packngo

Usage

To authenticate to the Packet API, you must have your API token exported in env var PACKET_AUTH_TOKEN.

This code snippet initializes Packet API client, and lists your Projects:

package main

import (
	"log"

	"github.com/packethost/packngo"
)

func main() {
	c, err := packngo.NewClient()
	if err != nil {
		log.Fatal(err)
	}

	ps, _, err := c.Projects.List(nil)
	if err != nil {
		log.Fatal(err)
	}
	for _, p := range ps {
		log.Println(p.ID, p.Name)
	}
}

This lib is used by the official terraform-provider-packet.

You can also learn a lot from the *_test.go sources. Almost all out tests touch the Packet API, so you can see how auth, querying and POSTing works. For example devices_test.go.

Linked resources in Get* and List* functions

Most of the Get and List functions have *GetOptions resp. *ListOptions paramters. If you supply them, you can specify which attributes of resources in the return set can be excluded or included. This is useful for linked resources, e.g members of a project, devices in a project.

Linked resources usually have only the Href attribute populated, allowing you to fetch them in another API call. But if you explicitly include the linked resoruce attribute, it will be populated in the result set of the linking resource.

For example, if you want to list users in a project, you can fetch the project via Projects.Get(pid, nil) call. Result from the call will be a Project struct which has Users []User attribute. The items in the []User slice only have the URL attribute non-zero, the rest of the fields will be type defaults. You can then parse the ID of the User resources and fetch them consequently. Or, you can use the ListOptions struct in the project fetch call to include the Users (members JSON tag) as

Projects.Get(pid, &packngo.ListOptions{Includes: []{'members'}})` 

Then, every item in the []User slice will have all (not only the URL) attributes populated. Following code illustrates the Includes and Excludes.

import (
	"log"

	"github.com/packethost/packngo"
)

func listProjectsAndUsers(lo *packngo.ListOptions) {
	c, err := packngo.NewClient()
	if err != nil {
		log.Fatal(err)
	}

	ps, _, err := c.Projects.List(lo)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Listing for listOptions %+v\n", lo)
	for _, p := range ps {
		log.Printf("project resource %s has %d users", p.Name, len(p.Users))
		for _, u := range p.Users {
			if u.Email != "" && u.FullName != "" {
				log.Printf("  user %s has email %s\n", u.FullName, u.Email)
			} else {
				log.Printf("  only got user link %s\n", u.URL)
			}
		}
	}
}

func main() {
	loMembers := &packngo.ListOptions{Includes: []string{"members"}}
	loMembersOut := &packngo.ListOptions{Excludes: []string{"members"}}
	listProjectsAndUsers(loMembers)
	listProjectsAndUsers(nil)
	listProjectsAndUsers(loMembersOut)
}

Acceptance Tests

If you want to run tests against the actual Packet API, you must set envvar PACKET_TEST_ACTUAL_API to non-empty string for the go test. The device tests wait for the device creation, so it's best to run a few in parallel.

To run a particular test, you can do

$ PACKNGO_TEST_ACTUAL_API=1 go test -v -run=TestAccDeviceBasic

If you want to see HTTP requests, set the PACKNGO_DEBUG env var to non-empty string, for example:

$ PACKNGO_DEBUG=1 PACKNGO_TEST_ACTUAL_API=1 go test -v -run=TestAccVolumeUpdate

Committing

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

Documentation

Index

Constants

View Source
const (
	AzureProviderID = "ed5de8e0-77a9-4d3b-9de0-65281d3aa831"
)

Variables

View Source
var (
	Facilities = []string{
		"yyz1", "nrt1", "atl1", "mrs1", "hkg1", "ams1",
		"ewr1", "sin1", "dfw1", "lax1", "syd1", "sjc1",
		"ord1", "iad1", "fra1", "sea1", "dfw2"}
	FacilityFeatures = []string{
		"baremetal", "layer_2", "backend_transfer", "storage", "global_ipv4"}
	UtilizationLevels = []string{"unavailable", "critical", "limited", "normal"}
	DevicePlans       = []string{"c2.medium.x86", "g2.large.x86",
		"m2.xlarge.x86", "x2.xlarge.x86", "baremetal_2a", "baremetal_2a2",
		"baremetal_1", "baremetal_3", "baremetal_2", "baremetal_s",
		"baremetal_0", "baremetal_1e",
	}
)

Functions

func StreamToString

func StreamToString(stream io.Reader) string

StreamToString converts a reader to a string

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 AddressRequest added in v0.2.0

type AddressRequest struct {
	AddressFamily int  `json:"address_family"`
	Public        bool `json:"public"`
}

type AddressStruct added in v0.2.0

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

AddressStruct is a helper type for request/response with dict like {"address": ... }

type AvailableRequest added in v0.2.0

type AvailableRequest struct {
	CIDR int `json:"cidr"`
}

AvailableRequest is a type for listing available addresses from a reserved block.

type AvailableResponse added in v0.2.0

type AvailableResponse struct {
	Available []string `json:"available"`
}

AvailableResponse is a type for listing of available addresses from a reserved block.

type BGPConfig added in v0.2.0

type BGPConfig struct {
	ID             string       `json:"id,omitempty"`
	Status         string       `json:"status,omitempty"`
	DeploymentType string       `json:"deployment_type,omitempty"`
	Asn            int          `json:"asn,omitempty"`
	RouteObject    string       `json:"route_object,omitempty"`
	Md5            string       `json:"md5,omitempty"`
	MaxPrefix      int          `json:"max_prefix,omitempty"`
	Project        Project      `json:"project,omitempty"`
	CreatedAt      Timestamp    `json:"created_at,omitempty"`
	RequestedAt    Timestamp    `json:"requested_at,omitempty"`
	Sessions       []BGPSession `json:"sessions,omitempty"`
	Href           string       `json:"href,omitempty"`
}

BGPConfig represents a Packet BGP Config

type BGPConfigService added in v0.2.0

type BGPConfigService interface {
	Get(projectID string, getOpt *GetOptions) (*BGPConfig, *Response, error)
	Create(string, CreateBGPConfigRequest) (*Response, error)
}

BGPConfigService interface defines available BGP config methods

type BGPConfigServiceOp added in v0.2.0

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

BGPConfigServiceOp implements BgpConfigService

func (*BGPConfigServiceOp) Create added in v0.2.0

func (s *BGPConfigServiceOp) Create(projectID string, request CreateBGPConfigRequest) (*Response, error)

Create function

func (*BGPConfigServiceOp) Get added in v0.2.0

func (s *BGPConfigServiceOp) Get(projectID string, getOpt *GetOptions) (bgpConfig *BGPConfig, resp *Response, err error)

Get function

type BGPSession added in v0.2.0

type BGPSession struct {
	ID            string   `json:"id,omitempty"`
	Status        string   `json:"status,omitempty"`
	LearnedRoutes []string `json:"learned_routes,omitempty"`
	AddressFamily string   `json:"address_family,omitempty"`
	Device        Device   `json:"device,omitempty"`
	Href          string   `json:"href,omitempty"`
	DefaultRoute  *bool    `json:"default_route,omitempty"`
}

BGPSession represents a Packet BGP Session

type BGPSessionService added in v0.2.0

type BGPSessionService interface {
	Get(string, *GetOptions) (*BGPSession, *Response, error)
	Create(string, CreateBGPSessionRequest) (*BGPSession, *Response, error)
	Delete(string) (*Response, error)
}

BGPSessionService interface defines available BGP session methods

type BGPSessionServiceOp added in v0.2.0

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

BGPSessionServiceOp implements BgpSessionService

func (*BGPSessionServiceOp) Create added in v0.2.0

func (s *BGPSessionServiceOp) Create(deviceID string, request CreateBGPSessionRequest) (*BGPSession, *Response, error)

Create function

func (*BGPSessionServiceOp) Delete added in v0.2.0

func (s *BGPSessionServiceOp) Delete(id string) (*Response, error)

Delete function

func (*BGPSessionServiceOp) Get added in v0.2.0

func (s *BGPSessionServiceOp) Get(id string, getOpt *GetOptions) (session *BGPSession, response *Response, err error)

Get function

type BackToL3Request added in v0.2.0

type BackToL3Request struct {
	RequestIPs []AddressRequest `json:"request_ips"`
}

type Batch added in v0.2.0

type Batch struct {
	ID        string     `json:"id"`
	State     string     `json:"state,omitempty"`
	Quantity  int32      `json:"quantity,omitempty"`
	CreatedAt *Timestamp `json:"created_at,omitempty"`
	Href      string     `json:"href,omitempty"`
	Project   Href       `json:"project,omitempty"`
	Devices   []Device   `json:"devices,omitempty"`
}

Batch type

type BatchCreateDevice added in v0.2.0

type BatchCreateDevice struct {
	DeviceCreateRequest
	Quantity               int32 `json:"quantity"`
	FacilityDiversityLevel int32 `json:"facility_diversity_level,omitempty"`
}

BatchCreateDevice type used to describe batch instances

type BatchCreateRequest added in v0.2.0

type BatchCreateRequest struct {
	Batches []BatchCreateDevice `json:"batches"`
}

BatchCreateRequest type used to create batch of device instances

type BatchService added in v0.2.0

type BatchService interface {
	Get(batchID string, getOpt *GetOptions) (*Batch, *Response, error)
	List(ProjectID string, listOpt *ListOptions) ([]Batch, *Response, error)
	Create(projectID string, batches *BatchCreateRequest) ([]Batch, *Response, error)
	Delete(string, bool) (*Response, error)
}

BatchService interface defines available batch methods

type BatchServiceOp added in v0.2.0

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

BatchServiceOp implements BatchService

func (*BatchServiceOp) Create added in v0.2.0

func (s *BatchServiceOp) Create(projectID string, request *BatchCreateRequest) ([]Batch, *Response, error)

Create function to create batch of device instances

func (*BatchServiceOp) Delete added in v0.2.0

func (s *BatchServiceOp) Delete(id string, removeDevices bool) (*Response, error)

Delete function to remove an instance batch

func (*BatchServiceOp) Get added in v0.2.0

func (s *BatchServiceOp) Get(batchID string, getOpt *GetOptions) (*Batch, *Response, error)

Get returns batch details

func (*BatchServiceOp) List added in v0.2.0

func (s *BatchServiceOp) List(projectID string, listOpt *ListOptions) (batches []Batch, resp *Response, err error)

List returns batches on a project

type BillingAddress added in v0.2.0

type BillingAddress struct {
	StreetAddress string `json:"street_address,omitempty"`
	PostalCode    string `json:"postal_code,omitempty"`
	CountryCode   string `json:"country_code_alpha2,omitempty"`
}

type BondRequest added in v0.2.0

type BondRequest struct {
	PortID     string `json:"id"`
	BulkEnable bool   `json:"bulk_enable"`
}

type CapacityInput added in v0.2.0

type CapacityInput struct {
	Servers []ServerInfo `json:"servers,omitempty"`
}

CapacityInput struct

type CapacityList added in v0.2.0

type CapacityList struct {
	Capacity CapacityReport `json:"capacity,omitempty"`
}

CapacityList struct

type CapacityPerBaremetal added in v0.2.0

type CapacityPerBaremetal struct {
	Level string `json:"level,omitempty"`
}

CapacityPerBaremetal struct

type CapacityReport added in v0.2.0

type CapacityReport map[string]map[string]CapacityPerBaremetal

CapacityReport map

type CapacityService added in v0.2.0

type CapacityService interface {
	List() (*CapacityReport, *Response, error)
	Check(*CapacityInput) (*CapacityInput, *Response, error)
}

CapacityService interface defines available capacity methods

type CapacityServiceOp added in v0.2.0

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

CapacityServiceOp implements CapacityService

func (*CapacityServiceOp) Check added in v0.2.0

func (s *CapacityServiceOp) Check(input *CapacityInput) (cap *CapacityInput, resp *Response, err error)

Check validates if a deploy can be fulfilled.

func (*CapacityServiceOp) List added in v0.2.0

List returns a list of facilities and plans with their current capacity.

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
	DeviceIPs              DeviceIPService
	DevicePorts            DevicePortService
	ProjectIPs             ProjectIPService
	ProjectVirtualNetworks ProjectVirtualNetworkService
	Volumes                VolumeService
	VolumeAttachments      VolumeAttachmentService
	SpotMarket             SpotMarketService
	SpotMarketRequests     SpotMarketRequestService
	Organizations          OrganizationService
	BGPSessions            BGPSessionService
	BGPConfig              BGPConfigService
	CapacityService        CapacityService
	Batches                BatchService
	TwoFactorAuth          TwoFactorAuthService
	VPN                    VPNService
	HardwareReservations   HardwareReservationService
	Events                 EventService
	Notifications          NotificationService
	Connects               ConnectService
	// contains filtered or unexported fields
}

Client is the base API Client

func NewClient

func NewClient() (*Client, error)

NewClient initializes and returns a Client

func NewClientWithAuth added in v0.2.0

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

NewClientWithAuth 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)

NewClientWithBaseURL returns a Client pointing to nonstandard API URL, e.g. for mocking the remote API

func (*Client) Do

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

Do executes the http request

func (*Client) DoRequest added in v0.2.0

func (c *Client) DoRequest(method, path string, body, v interface{}) (*Response, error)

DoRequest is a convenience method, it calls NewRequest followed by Do v is the interface to unmarshal the response JSON into

func (*Client) DoRequestWithHeader added in v0.2.0

func (c *Client) DoRequestWithHeader(method string, headers map[string]string, path string, body, v interface{}) (*Response, error)

DoRequestWithHeader same as DoRequest

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 Connect added in v0.2.0

type Connect struct {
	ID              string `json:"id"`
	Status          string `json:"status"`
	Name            string `json:"name"`
	ProjectID       string `json:"project_id"`
	ProviderID      string `json:"provider_id"`
	ProviderPayload string `json:"provider_payload"`
	Facility        string `json:"facility"`
	PortSpeed       int    `json:"port_speed"`
	VLAN            int    `json:"vlan"`
	Description     string `json:"description,omitempty"`
}

type ConnectCreateRequest added in v0.2.0

type ConnectCreateRequest struct {
	Name            string   `json:"name"`
	ProjectID       string   `json:"project_id"`
	ProviderID      string   `json:"provider_id"`
	ProviderPayload string   `json:"provider_payload"`
	Facility        string   `json:"facility"`
	PortSpeed       int      `json:"port_speed"`
	VLAN            int      `json:"vlan"`
	Tags            []string `json:"tags,omitempty"`
	Description     string   `json:"description,omitempty"`
}

type ConnectService added in v0.2.0

type ConnectService interface {
	List(string, *ListOptions) ([]Connect, *Response, error)
	Get(string, string, *GetOptions) (*Connect, *Response, error)
	Delete(string, string) (*Response, error)
	Create(*ConnectCreateRequest) (*Connect, *Response, error)
	Provision(string, string) (*Connect, *Response, error)
	Deprovision(string, string, bool) (*Connect, *Response, error)
}

type ConnectServiceOp added in v0.2.0

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

func (*ConnectServiceOp) Create added in v0.2.0

func (c *ConnectServiceOp) Create(createRequest *ConnectCreateRequest) (*Connect, *Response, error)

func (*ConnectServiceOp) Delete added in v0.2.0

func (c *ConnectServiceOp) Delete(connectID, projectID string) (*Response, error)

func (*ConnectServiceOp) Deprovision added in v0.2.0

func (c *ConnectServiceOp) Deprovision(connectID, projectID string, delete bool) (*Connect, *Response, error)

func (*ConnectServiceOp) Get added in v0.2.0

func (c *ConnectServiceOp) Get(connectID, projectID string, getOpt *GetOptions) (*Connect, *Response, error)

func (*ConnectServiceOp) List added in v0.2.0

func (c *ConnectServiceOp) List(projectID string, listOpt *ListOptions) (connects []Connect, resp *Response, err error)

func (*ConnectServiceOp) Provision added in v0.2.0

func (c *ConnectServiceOp) Provision(connectID, projectID string) (*Connect, *Response, error)

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 CreateBGPConfigRequest added in v0.2.0

type CreateBGPConfigRequest struct {
	DeploymentType string `json:"deployment_type,omitempty"`
	Asn            int    `json:"asn,omitempty"`
	Md5            string `json:"md5,omitempty"`
	UseCase        string `json:"use_case,omitempty"`
}

CreateBGPConfigRequest struct

type CreateBGPSessionRequest added in v0.2.0

type CreateBGPSessionRequest struct {
	AddressFamily string `json:"address_family"`
	DefaultRoute  *bool  `json:"default_route,omitempty"`
}

CreateBGPSessionRequest struct

type Device

type Device struct {
	DeviceRaw
	NetworkType string
}

func (*Device) GetNetworkInfo added in v0.2.0

func (d *Device) GetNetworkInfo() NetworkInfo

func (Device) String

func (d Device) String() string

func (*Device) UnmarshalJSON added in v0.2.0

func (d *Device) UnmarshalJSON(b []byte) error

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"`
	Storage               string     `json:"storage,omitempty"`
	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"`
	HardwareReservationID string     `json:"hardware_reservation_id,omitempty"`
	SpotInstance          bool       `json:"spot_instance,omitempty"`
	SpotPriceMax          float64    `json:"spot_price_max,omitempty,string"`
	TerminationTime       *Timestamp `json:"termination_time,omitempty"`
	CustomData            string     `json:"customdata,omitempty"`
	// UserSSHKeys is a list of user UUIDs - essentialy a list of
	// collaborators. The users must be a collaborator in the same project
	// where the device is created. The user's SSH keys then go to the
	// device.
	UserSSHKeys []string `json:"user_ssh_keys,omitempty"`
	// Project SSHKeys is a list of SSHKeys resource UUIDs. If this param
	// is supplied, only the listed SSHKeys will go to the device.
	// Any other Project SSHKeys and any User SSHKeys will not be present
	// in the device.
	ProjectSSHKeys []string                 `json:"project_ssh_keys,omitempty"`
	Features       map[string]string        `json:"features,omitempty"`
	IPAddresses    []IPAddressCreateRequest `json:"ip_addresses,omitempty"`
}

DeviceCreateRequest type used to create a Packet device

func (DeviceCreateRequest) String

func (d DeviceCreateRequest) String() string

type DeviceIPService added in v0.2.0

type DeviceIPService interface {
	Assign(deviceID string, assignRequest *AddressStruct) (*IPAddressAssignment, *Response, error)
	Unassign(assignmentID string) (*Response, error)
	Get(assignmentID string, getOpt *GetOptions) (*IPAddressAssignment, *Response, error)
}

DeviceIPService handles assignment of addresses from reserved blocks to instances in a project.

type DeviceIPServiceOp added in v0.2.0

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

DeviceIPServiceOp is interface for IP-address assignment methods.

func (*DeviceIPServiceOp) Assign added in v0.2.0

func (i *DeviceIPServiceOp) Assign(deviceID string, assignRequest *AddressStruct) (*IPAddressAssignment, *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 (*DeviceIPServiceOp) Get added in v0.2.0

func (i *DeviceIPServiceOp) Get(assignmentID string, getOpt *GetOptions) (*IPAddressAssignment, *Response, error)

Get returns assignment by ID.

func (*DeviceIPServiceOp) Unassign added in v0.2.0

func (i *DeviceIPServiceOp) Unassign(assignmentID string) (*Response, error)

Unassign unassigns an IP address from the device to which it is currently assigned. 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 DevicePortService added in v0.2.0

type DevicePortService interface {
	Assign(*PortAssignRequest) (*Port, *Response, error)
	Unassign(*PortAssignRequest) (*Port, *Response, error)
	AssignNative(*PortAssignRequest) (*Port, *Response, error)
	UnassignNative(string) (*Port, *Response, error)
	Bond(*BondRequest) (*Port, *Response, error)
	Disbond(*DisbondRequest) (*Port, *Response, error)
	DeviceToNetworkType(string, string) (*Device, error)
	DeviceNetworkType(string) (string, error)
	PortToLayerTwo(string) (*Port, *Response, error)
	PortToLayerThree(string) (*Port, *Response, error)
	DeviceToLayerTwo(string) (*Device, error)
	DeviceToLayerThree(string) (*Device, error)
	GetBondPort(string) (*Port, error)
	GetPortByName(string, string) (*Port, error)
}

DevicePortService handles operations on a port which belongs to a particular device

type DevicePortServiceOp added in v0.2.0

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

func (*DevicePortServiceOp) Assign added in v0.2.0

func (*DevicePortServiceOp) AssignNative added in v0.2.0

func (i *DevicePortServiceOp) AssignNative(par *PortAssignRequest) (*Port, *Response, error)

func (*DevicePortServiceOp) Bond added in v0.2.0

func (i *DevicePortServiceOp) Bond(br *BondRequest) (*Port, *Response, error)

func (*DevicePortServiceOp) DeviceNetworkType added in v0.2.0

func (i *DevicePortServiceOp) DeviceNetworkType(deviceID string) (string, error)

func (*DevicePortServiceOp) DeviceToLayerThree added in v0.2.0

func (i *DevicePortServiceOp) DeviceToLayerThree(deviceID string) (*Device, error)

func (*DevicePortServiceOp) DeviceToLayerTwo added in v0.2.0

func (i *DevicePortServiceOp) DeviceToLayerTwo(deviceID string) (*Device, error)

DeviceToLayerTwo converts device to L2 networking. Use bond0 to attach VLAN.

func (*DevicePortServiceOp) DeviceToNetworkType added in v0.2.0

func (i *DevicePortServiceOp) DeviceToNetworkType(deviceID string, nType string) (*Device, error)

func (*DevicePortServiceOp) Disbond added in v0.2.0

func (i *DevicePortServiceOp) Disbond(dr *DisbondRequest) (*Port, *Response, error)

func (*DevicePortServiceOp) GetBondPort added in v0.2.0

func (i *DevicePortServiceOp) GetBondPort(deviceID string) (*Port, error)

func (*DevicePortServiceOp) GetPortByName added in v0.2.0

func (i *DevicePortServiceOp) GetPortByName(deviceID, name string) (*Port, error)

func (*DevicePortServiceOp) PortToLayerThree added in v0.2.0

func (i *DevicePortServiceOp) PortToLayerThree(portID string) (*Port, *Response, error)

func (*DevicePortServiceOp) PortToLayerTwo added in v0.2.0

func (i *DevicePortServiceOp) PortToLayerTwo(portID string) (*Port, *Response, error)

func (*DevicePortServiceOp) Unassign added in v0.2.0

func (i *DevicePortServiceOp) Unassign(par *PortAssignRequest) (*Port, *Response, error)

func (*DevicePortServiceOp) UnassignNative added in v0.2.0

func (i *DevicePortServiceOp) UnassignNative(portID string) (*Port, *Response, error)

type DeviceRaw added in v0.2.0

type DeviceRaw 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"`
	Storage             map[string]interface{} `json:"storage,omitempty"`
	Tags                []string               `json:"tags,omitempty"`
	Network             []*IPAddressAssignment `json:"ip_addresses"`
	Volumes             []*Volume              `json:"volumes"`
	OS                  *OS                    `json:"operating_system,omitempty"`
	Plan                *Plan                  `json:"plan,omitempty"`
	Facility            *Facility              `json:"facility,omitempty"`
	Project             *Project               `json:"project,omitempty"`
	ProvisionEvents     []*Event               `json:"provisioning_events,omitempty"`
	ProvisionPer        float32                `json:"provisioning_percentage,omitempty"`
	UserData            string                 `json:"userdata,omitempty"`
	RootPassword        string                 `json:"root_password,omitempty"`
	IPXEScriptURL       string                 `json:"ipxe_script_url,omitempty"`
	AlwaysPXE           bool                   `json:"always_pxe,omitempty"`
	HardwareReservation Href                   `json:"hardware_reservation,omitempty"`
	SpotInstance        bool                   `json:"spot_instance,omitempty"`
	SpotPriceMax        float64                `json:"spot_price_max,omitempty"`
	TerminationTime     *Timestamp             `json:"termination_time,omitempty"`
	NetworkPorts        []Port                 `json:"network_ports,omitempty"`
	CustomData          map[string]interface{} `json:"customdata,omitempty"`
	SSHKeys             []SSHKey               `json:"ssh_keys,omitempty"`
	ShortID             string                 `json:"short_id,omitempty"`
}

DeviceRaw represents a Packet device from API

func (DeviceRaw) GetNetworkType added in v0.2.0

func (d DeviceRaw) GetNetworkType() (string, error)

type DeviceService

type DeviceService interface {
	List(ProjectID string, listOpt *ListOptions) ([]Device, *Response, error)
	Get(DeviceID string, getOpt *GetOptions) (*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)
	ListBGPSessions(deviceID string, listOpt *ListOptions) ([]BGPSession, *Response, error)
	ListEvents(string, *ListOptions) ([]Event, *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, getOpt *GetOptions) (*Device, *Response, error)

Get returns a device by id

func (*DeviceServiceOp) List

func (s *DeviceServiceOp) List(projectID string, listOpt *ListOptions) (devices []Device, resp *Response, err error)

List returns devices on a project

func (*DeviceServiceOp) ListBGPSessions added in v0.2.0

func (s *DeviceServiceOp) ListBGPSessions(deviceID string, listOpt *ListOptions) (bgpSessions []BGPSession, resp *Response, err error)

ListBGPSessions returns all BGP Sessions associated with the device

func (*DeviceServiceOp) ListEvents added in v0.2.0

func (s *DeviceServiceOp) ListEvents(deviceID string, listOpt *ListOptions) ([]Event, *Response, error)

ListEvents returns list of device events

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 "unlocked"

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,omitempty"`
	Description   *string   `json:"description,omitempty"`
	UserData      *string   `json:"userdata,omitempty"`
	Locked        *bool     `json:"locked,omitempty"`
	Tags          *[]string `json:"tags,omitempty"`
	AlwaysPXE     *bool     `json:"always_pxe,omitempty"`
	IPXEScriptURL *string   `json:"ipxe_script_url,omitempty"`
	CustomData    *string   `json:"customdata,omitempty"`
}

DeviceUpdateRequest type used to update a Packet device

type DisbondRequest added in v0.2.0

type DisbondRequest struct {
	PortID      string `json:"id"`
	BulkDisable bool   `json:"bulk_disable"`
}

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 EmailRequest added in v0.2.0

type EmailRequest struct {
	Address string `json:"address,omitempty"`
	Default *bool  `json:"default,omitempty"`
}

EmailRequest type used to add an email address to the current user

type EmailService

type EmailService interface {
	Get(string, *GetOptions) (*Email, *Response, error)
	Create(*EmailRequest) (*Email, *Response, error)
	Update(string, *EmailRequest) (*Email, *Response, error)
	Delete(string) (*Response, error)
}

EmailService interface defines available email methods

type EmailServiceOp

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

EmailServiceOp implements EmailService

func (*EmailServiceOp) Create added in v0.2.0

func (s *EmailServiceOp) Create(request *EmailRequest) (*Email, *Response, error)

Create adds a new email address to the current user.

func (*EmailServiceOp) Delete added in v0.2.0

func (s *EmailServiceOp) Delete(emailID string) (*Response, error)

Delete removes the email addres from the current user account

func (*EmailServiceOp) Get

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

Get retrieves an email by id

func (*EmailServiceOp) Update added in v0.2.0

func (s *EmailServiceOp) Update(emailID string, request *EmailRequest) (*Email, *Response, error)

Update email parameters

type ErrorResponse

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

ErrorResponse is the http response used on errors

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Event added in v0.2.0

type Event struct {
	ID            string     `json:"id,omitempty"`
	State         string     `json:"state,omitempty"`
	Type          string     `json:"type,omitempty"`
	Body          string     `json:"body,omitempty"`
	Relationships []Href     `json:"relationships,omitempty"`
	Interpolated  string     `json:"interpolated,omitempty"`
	CreatedAt     *Timestamp `json:"created_at,omitempty"`
	Href          string     `json:"href,omitempty"`
}

Event struct

type EventService added in v0.2.0

type EventService interface {
	List(*ListOptions) ([]Event, *Response, error)
	Get(string, *GetOptions) (*Event, *Response, error)
}

EventService interface defines available event functions

type EventServiceOp added in v0.2.0

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

EventServiceOp implements EventService

func (*EventServiceOp) Get added in v0.2.0

func (s *EventServiceOp) Get(eventID string, getOpt *GetOptions) (*Event, *Response, error)

Get returns an event by ID

func (*EventServiceOp) List added in v0.2.0

func (s *EventServiceOp) List(listOpt *ListOptions) ([]Event, *Response, error)

List returns all events

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(*ListOptions) ([]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(listOpt *ListOptions) ([]Facility, *Response, error)

List returns all 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 GetOptions added in v0.2.0

type GetOptions struct {
	Includes []string
	Excludes []string
}

type HardwareReservation added in v0.2.0

type HardwareReservation struct {
	ID            string    `json:"id,omitempty"`
	ShortID       string    `json:"short_id,omitempty"`
	Facility      Facility  `json:"facility,omitempty"`
	Plan          Plan      `json:"plan,omitempty"`
	Provisionable bool      `json:"provisionable,omitempty"`
	Spare         bool      `json:"spare,omitempty"`
	SwitchUUID    string    `json:"switch_uuid,omitempty"`
	Intervals     int       `json:"intervals,omitempty"`
	CurrentPeriod int       `json:"current_period,omitempty"`
	Href          string    `json:"href,omitempty"`
	Project       Project   `json:"project,omitempty"`
	Device        *Device   `json:"device,omitempty"`
	CreatedAt     Timestamp `json:"created_at,omitempty"`
}

HardwareReservation struct

type HardwareReservationService added in v0.2.0

type HardwareReservationService interface {
	Get(hardwareReservationID string, getOpt *GetOptions) (*HardwareReservation, *Response, error)
	List(projectID string, listOpt *ListOptions) ([]HardwareReservation, *Response, error)
	Move(string, string) (*HardwareReservation, *Response, error)
}

HardwareReservationService interface defines available hardware reservation functions

type HardwareReservationServiceOp added in v0.2.0

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

HardwareReservationServiceOp implements HardwareReservationService

func (*HardwareReservationServiceOp) Get added in v0.2.0

func (s *HardwareReservationServiceOp) Get(hardwareReservationdID string, getOpt *GetOptions) (*HardwareReservation, *Response, error)

Get returns a single hardware reservation

func (*HardwareReservationServiceOp) List added in v0.2.0

func (s *HardwareReservationServiceOp) List(projectID string, listOpt *ListOptions) (reservations []HardwareReservation, resp *Response, err error)

List returns all hardware reservations for a given project

func (*HardwareReservationServiceOp) Move added in v0.2.0

func (s *HardwareReservationServiceOp) Move(hardwareReservationdID, projectID string) (*HardwareReservation, *Response, error)

Move a hardware reservation to another project

type Href added in v0.2.0

type Href struct {
	Href string `json:"href"`
}

Href is an API link

type IPAddressAssignment added in v0.2.0

type IPAddressAssignment struct {
	IpAddressCommon
	AssignedTo Href `json:"assigned_to"`
}

IPAddressAssignment is created when an IP address from reservation block is assigned to a device.

func (IPAddressAssignment) String added in v0.2.0

func (i IPAddressAssignment) String() string

type IPAddressCreateRequest added in v0.2.0

type IPAddressCreateRequest struct {
	AddressFamily int  `json:"address_family"`
	Public        bool `json:"public"`
}

type IPAddressReservation added in v0.2.0

type IPAddressReservation struct {
	IpAddressCommon
	Assignments []Href    `json:"assignments"`
	Facility    *Facility `json:"facility,omitempty"`
	Available   string    `json:"available"`
	Addon       bool      `json:"addon"`
	Bill        bool      `json:"bill"`
	Description *string   `json:"details"`
}

IPAddressReservation is created when user sends IP reservation request for a project (considering it's within quota).

func (IPAddressReservation) String added in v0.2.0

func (i IPAddressReservation) String() string

type IPReservationRequest

type IPReservationRequest struct {
	Type        string  `json:"type"`
	Quantity    int     `json:"quantity"`
	Description string  `json:"details,omitempty"`
	Facility    *string `json:"facility,omitempty"`
}

IPReservationRequest represents the body of a reservation request.

type IpAddressCommon added in v0.2.0

type IpAddressCommon 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"`
	Created       string `json:"created_at,omitempty"`
	Updated       string `json:"updated_at,omitempty"`
	Href          string `json:"href"`
	Management    bool   `json:"management"`
	Manageable    bool   `json:"manageable"`
	Project       Href   `json:"project"`
	Global        *bool  `json:"global_ip"`
}

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"`
	Includes []string
	Excludes []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 NetworkInfo added in v0.2.0

type NetworkInfo struct {
	PublicIPv4  string
	PublicIPv6  string
	PrivateIPv4 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 Notification added in v0.2.0

type Notification struct {
	ID        string    `json:"id,omitempty"`
	Type      string    `json:"type,omitempty"`
	Body      string    `json:"body,omitempty"`
	Severity  string    `json:"severity,omitempty"`
	Read      bool      `json:"read,omitempty"`
	Context   string    `json:"context,omitempty"`
	CreatedAt Timestamp `json:"created_at,omitempty"`
	UpdatedAt Timestamp `json:"updated_at,omitempty"`
	User      Href      `json:"user,omitempty"`
	Href      string    `json:"href,omitempty"`
}

Notification struct

type NotificationService added in v0.2.0

type NotificationService interface {
	List(*ListOptions) ([]Notification, *Response, error)
	Get(string, *GetOptions) (*Notification, *Response, error)
	MarkAsRead(string) (*Notification, *Response, error)
}

NotificationService interface defines available event functions

type NotificationServiceOp added in v0.2.0

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

NotificationServiceOp implements NotificationService

func (*NotificationServiceOp) Get added in v0.2.0

func (s *NotificationServiceOp) Get(notificationID string, getOpt *GetOptions) (*Notification, *Response, error)

Get returns a notification by ID

func (*NotificationServiceOp) List added in v0.2.0

func (s *NotificationServiceOp) List(listOpt *ListOptions) ([]Notification, *Response, error)

List returns all notifications

func (*NotificationServiceOp) MarkAsRead added in v0.2.0

func (s *NotificationServiceOp) MarkAsRead(notificationID string) (*Notification, *Response, error)

Marks notification as read by ID

type OS

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

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 Organization added in v0.2.0

type Organization struct {
	ID           string    `json:"id"`
	Name         string    `json:"name,omitempty"`
	Description  string    `json:"description,omitempty"`
	Website      string    `json:"website,omitempty"`
	Twitter      string    `json:"twitter,omitempty"`
	Created      string    `json:"created_at,omitempty"`
	Updated      string    `json:"updated_at,omitempty"`
	Address      Address   `json:"address,omitempty"`
	TaxID        string    `json:"tax_id,omitempty"`
	MainPhone    string    `json:"main_phone,omitempty"`
	BillingPhone string    `json:"billing_phone,omitempty"`
	CreditAmount float64   `json:"credit_amount,omitempty"`
	LogoThumb    string    `json:"logo_thumb,omitempty"`
	Projects     []Project `json:"projects,omitempty"`
	URL          string    `json:"href,omitempty"`
	Users        []User    `json:"members,omitempty"`
	Owners       []User    `json:"owners,omitempty"`
}

Organization represents a Packet organization

func (Organization) String added in v0.2.0

func (o Organization) String() string

type OrganizationCreateRequest added in v0.2.0

type OrganizationCreateRequest struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Website     string `json:"website"`
	Twitter     string `json:"twitter"`
}

OrganizationCreateRequest type used to create a Packet organization

func (OrganizationCreateRequest) String added in v0.2.0

func (o OrganizationCreateRequest) String() string

type OrganizationService added in v0.2.0

type OrganizationService interface {
	List(*ListOptions) ([]Organization, *Response, error)
	Get(string, *GetOptions) (*Organization, *Response, error)
	Create(*OrganizationCreateRequest) (*Organization, *Response, error)
	Update(string, *OrganizationUpdateRequest) (*Organization, *Response, error)
	Delete(string) (*Response, error)
	ListPaymentMethods(string) ([]PaymentMethod, *Response, error)
	ListEvents(string, *ListOptions) ([]Event, *Response, error)
}

OrganizationService interface defines available organization methods

type OrganizationServiceOp added in v0.2.0

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

OrganizationServiceOp implements OrganizationService

func (*OrganizationServiceOp) Create added in v0.2.0

Create creates a new organization

func (*OrganizationServiceOp) Delete added in v0.2.0

func (s *OrganizationServiceOp) Delete(organizationID string) (*Response, error)

Delete deletes an organizationID

func (*OrganizationServiceOp) Get added in v0.2.0

func (s *OrganizationServiceOp) Get(organizationID string, getOpt *GetOptions) (*Organization, *Response, error)

Get returns a organization by id

func (*OrganizationServiceOp) List added in v0.2.0

func (s *OrganizationServiceOp) List(listOpt *ListOptions) (orgs []Organization, resp *Response, err error)

List returns the user's organizations

func (*OrganizationServiceOp) ListEvents added in v0.2.0

func (s *OrganizationServiceOp) ListEvents(organizationID string, listOpt *ListOptions) ([]Event, *Response, error)

ListEvents returns list of organization events

func (*OrganizationServiceOp) ListPaymentMethods added in v0.2.0

func (s *OrganizationServiceOp) ListPaymentMethods(organizationID string) ([]PaymentMethod, *Response, error)

ListPaymentMethods returns PaymentMethods for an organization

func (*OrganizationServiceOp) Update added in v0.2.0

Update updates an organization

type OrganizationUpdateRequest added in v0.2.0

type OrganizationUpdateRequest struct {
	Name        *string `json:"name,omitempty"`
	Description *string `json:"description,omitempty"`
	Website     *string `json:"website,omitempty"`
	Twitter     *string `json:"twitter,omitempty"`
}

OrganizationUpdateRequest type used to update a Packet organization

func (OrganizationUpdateRequest) String added in v0.2.0

func (o OrganizationUpdateRequest) String() string

type PaymentMethod added in v0.2.0

type PaymentMethod struct {
	ID             string         `json:"id"`
	Name           string         `json:"name,omitempty"`
	Created        string         `json:"created_at,omitempty"`
	Updated        string         `json:"updated_at,omitempty"`
	Nonce          string         `json:"nonce,omitempty"`
	Default        bool           `json:"default,omitempty"`
	Organization   Organization   `json:"organization,omitempty"`
	Projects       []Project      `json:"projects,omitempty"`
	Type           string         `json:"type,omitempty"`
	CardholderName string         `json:"cardholder_name,omitempty"`
	ExpMonth       string         `json:"expiration_month,omitempty"`
	ExpYear        string         `json:"expiration_year,omitempty"`
	Last4          string         `json:"last_4,omitempty"`
	BillingAddress BillingAddress `json:"billing_address,omitempty"`
	URL            string         `json:"href,omitempty"`
}

PaymentMethod represents a Packet payment method of an organization

func (PaymentMethod) String added in v0.2.0

func (pm PaymentMethod) String() string

type PaymentMethodCreateRequest added in v0.2.0

type PaymentMethodCreateRequest struct {
	Name           string `json:"name"`
	Nonce          string `json:"nonce"`
	CardholderName string `json:"cardholder_name,omitempty"`
	ExpMonth       string `json:"expiration_month,omitempty"`
	ExpYear        string `json:"expiration_year,omitempty"`
	BillingAddress string `json:"billing_address,omitempty"`
}

PaymentMethodCreateRequest type used to create a Packet payment method of an organization

func (PaymentMethodCreateRequest) String added in v0.2.0

func (pm PaymentMethodCreateRequest) String() string

type PaymentMethodService added in v0.2.0

type PaymentMethodService interface {
	List() ([]PaymentMethod, *Response, error)
	Get(string) (*PaymentMethod, *Response, error)
	Create(*PaymentMethodCreateRequest) (*PaymentMethod, *Response, error)
	Update(string, *PaymentMethodUpdateRequest) (*PaymentMethod, *Response, error)
	Delete(string) (*Response, error)
}

ProjectService interface defines available project methods

type PaymentMethodServiceOp added in v0.2.0

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

PaymentMethodServiceOp implements PaymentMethodService

type PaymentMethodUpdateRequest added in v0.2.0

type PaymentMethodUpdateRequest struct {
	Name           *string `json:"name,omitempty"`
	CardholderName *string `json:"cardholder_name,omitempty"`
	ExpMonth       *string `json:"expiration_month,omitempty"`
	ExpYear        *string `json:"expiration_year,omitempty"`
	BillingAddress *string `json:"billing_address,omitempty"`
}

PaymentMethodUpdateRequest type used to update a Packet payment method of an organization

func (PaymentMethodUpdateRequest) String added in v0.2.0

func (pm PaymentMethodUpdateRequest) String() string

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"`
	DeploymentTypes []string   `json:"deployment_types"`
	Class           string     `json:"class"`
	AvailableIn     []Facility `json:"available_in"`
}

Plan represents a Packet service plan

func (Plan) String

func (p Plan) String() string

type PlanService

type PlanService interface {
	List(*ListOptions) ([]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(listOpt *ListOptions) ([]Plan, *Response, error)

List method returns all available plans

type Port added in v0.2.0

type Port struct {
	ID                      string           `json:"id"`
	Type                    string           `json:"type"`
	Name                    string           `json:"name"`
	Data                    PortData         `json:"data"`
	NetworkType             string           `json:"network_type,omitempty"`
	NativeVirtualNetwork    *VirtualNetwork  `json:"native_virtual_network"`
	AttachedVirtualNetworks []VirtualNetwork `json:"virtual_networks"`
}

type PortAssignRequest added in v0.2.0

type PortAssignRequest struct {
	PortID           string `json:"id"`
	VirtualNetworkID string `json:"vnid"`
}

type PortData added in v0.2.0

type PortData struct {
	MAC    string `json:"mac"`
	Bonded bool   `json:"bonded"`
}

type PriceMap added in v0.2.0

type PriceMap map[string]map[string]float64

PriceMap is a map of [facility][plan]-> float Price

type Pricing

type Pricing struct {
	Hour  float32 `json:"hour,omitempty"`
	Month float32 `json:"month,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"`
	Organization    Organization  `json:"organization,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"`
	PaymentMethod   PaymentMethod `json:"payment_method,omitempty"`
	BackendTransfer bool          `json:"backend_transfer_enabled"`
}

Project represents a Packet project

func (Project) String

func (p Project) String() string

type ProjectCreateRequest

type ProjectCreateRequest struct {
	Name            string `json:"name"`
	PaymentMethodID string `json:"payment_method_id,omitempty"`
	OrganizationID  string `json:"organization_id,omitempty"`
}

ProjectCreateRequest type used to create a Packet project

func (ProjectCreateRequest) String

func (p ProjectCreateRequest) String() string

type ProjectIPService added in v0.2.0

type ProjectIPService interface {
	Get(reservationID string, getOpt *GetOptions) (*IPAddressReservation, *Response, error)
	List(projectID string) ([]IPAddressReservation, *Response, error)
	Request(projectID string, ipReservationReq *IPReservationRequest) (*IPAddressReservation, *Response, error)
	Remove(ipReservationID string) (*Response, error)
	AvailableAddresses(ipReservationID string, r *AvailableRequest) ([]string, *Response, error)
}

ProjectIPService handles reservation of IP address blocks for a project.

type ProjectIPServiceOp added in v0.2.0

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

ProjectIPServiceOp is interface for IP assignment methods.

func (*ProjectIPServiceOp) AvailableAddresses added in v0.2.0

func (i *ProjectIPServiceOp) AvailableAddresses(ipReservationID string, r *AvailableRequest) ([]string, *Response, error)

AvailableAddresses lists addresses available from a reserved block

func (*ProjectIPServiceOp) Get added in v0.2.0

func (i *ProjectIPServiceOp) Get(reservationID string, getOpt *GetOptions) (*IPAddressReservation, *Response, error)

Get returns reservation by ID.

func (*ProjectIPServiceOp) List added in v0.2.0

func (i *ProjectIPServiceOp) List(projectID string) ([]IPAddressReservation, *Response, error)

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

func (*ProjectIPServiceOp) Remove added in v0.2.0

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

Remove removes an IP reservation from the project.

func (*ProjectIPServiceOp) Request added in v0.2.0

func (i *ProjectIPServiceOp) Request(projectID string, ipReservationReq *IPReservationRequest) (*IPAddressReservation, *Response, error)

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

type ProjectService

type ProjectService interface {
	List(listOpt *ListOptions) ([]Project, *Response, error)
	Get(string, *GetOptions) (*Project, *Response, error)
	Create(*ProjectCreateRequest) (*Project, *Response, error)
	Update(string, *ProjectUpdateRequest) (*Project, *Response, error)
	Delete(string) (*Response, error)
	ListBGPSessions(projectID string, listOpt *ListOptions) ([]BGPSession, *Response, error)
	ListEvents(string, *ListOptions) ([]Event, *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, getOpt *GetOptions) (*Project, *Response, error)

Get returns a project by id

func (*ProjectServiceOp) List

func (s *ProjectServiceOp) List(listOpt *ListOptions) (projects []Project, resp *Response, err error)

List returns the user's projects

func (*ProjectServiceOp) ListBGPSessions added in v0.2.0

func (s *ProjectServiceOp) ListBGPSessions(projectID string, listOpt *ListOptions) (bgpSessions []BGPSession, resp *Response, err error)

ListBGPSessions returns all BGP Sessions associated with the project

func (*ProjectServiceOp) ListEvents added in v0.2.0

func (s *ProjectServiceOp) ListEvents(projectID string, listOpt *ListOptions) ([]Event, *Response, error)

ListEvents returns list of project events

func (*ProjectServiceOp) Update

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

Update updates a project

type ProjectUpdateRequest

type ProjectUpdateRequest struct {
	Name            *string `json:"name,omitempty"`
	PaymentMethodID *string `json:"payment_method_id,omitempty"`
	BackendTransfer *bool   `json:"backend_transfer_enabled,omitempty"`
}

ProjectUpdateRequest type used to update a Packet project

func (ProjectUpdateRequest) String

func (p ProjectUpdateRequest) String() string

type ProjectVirtualNetworkService added in v0.2.0

type ProjectVirtualNetworkService interface {
	List(projectID string, listOpt *ListOptions) (*VirtualNetworkListResponse, *Response, error)
	Create(*VirtualNetworkCreateRequest) (*VirtualNetwork, *Response, error)
	Get(string, *GetOptions) (*VirtualNetwork, *Response, error)
	Delete(virtualNetworkID string) (*Response, error)
}

DevicePortService handles operations on a port which belongs to a particular device

type ProjectVirtualNetworkServiceOp added in v0.2.0

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

func (*ProjectVirtualNetworkServiceOp) Create added in v0.2.0

func (*ProjectVirtualNetworkServiceOp) Delete added in v0.2.0

func (i *ProjectVirtualNetworkServiceOp) Delete(virtualNetworkID string) (*Response, error)

func (*ProjectVirtualNetworkServiceOp) Get added in v0.2.0

func (*ProjectVirtualNetworkServiceOp) List added in v0.2.0

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)
	ProjectList(string) ([]SSHKey, *Response, error)
	Get(string, *GetOptions) (*SSHKey, *Response, error)
	Create(*SSHKeyCreateRequest) (*SSHKey, *Response, error)
	Update(string, *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, getOpt *GetOptions) (*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) ProjectList added in v0.2.0

func (s *SSHKeyServiceOp) ProjectList(projectID string) ([]SSHKey, *Response, error)

ProjectList lists ssh keys of a project

func (*SSHKeyServiceOp) Update

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

Update updates an ssh key

type SSHKeyUpdateRequest

type SSHKeyUpdateRequest struct {
	Label *string `json:"label,omitempty"`
	Key   *string `json:"key,omitempty"`
}

SSHKeyUpdateRequest type used to update an ssh key

func (SSHKeyUpdateRequest) String

func (s SSHKeyUpdateRequest) String() string

type ServerInfo added in v0.2.0

type ServerInfo struct {
	Facility  string `json:"facility,omitempty"`
	Plan      string `json:"plan,omitempty"`
	Quantity  int    `json:"quantity,omitempty"`
	Available bool   `json:"available,omitempty"`
}

ServerInfo struct

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 SpotMarketRequest added in v0.2.0

type SpotMarketRequest struct {
	SpotMarketRequestCreateRequest
	ID         string     `json:"id"`
	Devices    []Device   `json:"devices"`
	Facilities []Facility `json:"facilities"`
	Project    Project    `json:"project"`
	Href       string     `json:"href"`
	Plan       Plan       `json:"plan"`
}

type SpotMarketRequestCreateRequest added in v0.2.0

type SpotMarketRequestCreateRequest struct {
	DevicesMax  int        `json:"devices_max"`
	DevicesMin  int        `json:"devices_min"`
	EndAt       *Timestamp `json:"end_at,omitempty"`
	FacilityIDs []string   `json:"facilities"`
	MaxBidPrice float64    `json:"max_bid_price"`

	Parameters SpotMarketRequestInstanceParameters `json:"instance_parameters"`
}

type SpotMarketRequestInstanceParameters added in v0.2.0

type SpotMarketRequestInstanceParameters struct {
	AlwaysPXE       bool       `json:"always_pxe,omitempty"`
	BillingCycle    string     `json:"billing_cycle"`
	CustomData      string     `json:"customdata,omitempty"`
	Description     string     `json:"description,omitempty"`
	Features        []string   `json:"features,omitempty"`
	Hostname        string     `json:"hostname,omitempty"`
	Hostnames       []string   `json:"hostnames,omitempty"`
	Locked          bool       `json:"locked,omitempty"`
	OperatingSystem string     `json:"operating_system"`
	Plan            string     `json:"plan"`
	ProjectSSHKeys  []string   `json:"project_ssh_keys,omitempty"`
	Tags            []string   `json:"tags"`
	TerminationTime *Timestamp `json:"termination_time,omitempty"`
	UserSSHKeys     []string   `json:"user_ssh_keys,omitempty"`
	UserData        string     `json:"userdata"`
}

type SpotMarketRequestService added in v0.2.0

type SpotMarketRequestServiceOp added in v0.2.0

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

func (*SpotMarketRequestServiceOp) Create added in v0.2.0

func (*SpotMarketRequestServiceOp) Delete added in v0.2.0

func (s *SpotMarketRequestServiceOp) Delete(id string, forceDelete bool) (*Response, error)

func (*SpotMarketRequestServiceOp) Get added in v0.2.0

func (*SpotMarketRequestServiceOp) List added in v0.2.0

type SpotMarketService added in v0.2.0

type SpotMarketService interface {
	Prices() (PriceMap, *Response, error)
}

SpotMarketService expooses Spot Market methods

type SpotMarketServiceOp added in v0.2.0

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

SpotMarketServiceOp implements SpotMarketService

func (*SpotMarketServiceOp) Prices added in v0.2.0

func (s *SpotMarketServiceOp) Prices() (PriceMap, *Response, error)

Prices gets current PriceMap from the API

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 TwoFactorAuthService added in v0.2.0

type TwoFactorAuthService interface {
	EnableApp(string) (*Response, error)
	DisableApp(string) (*Response, error)
	EnableSms(string) (*Response, error)
	DisableSms(string) (*Response, error)
	ReceiveSms() (*Response, error)
	SeedApp() (string, *Response, error)
}

TwoFactorAuthService interface defines available two factor authentication functions

type TwoFactorAuthServiceOp added in v0.2.0

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

TwoFactorAuthServiceOp implements TwoFactorAuthService

func (*TwoFactorAuthServiceOp) DisableApp added in v0.2.0

func (s *TwoFactorAuthServiceOp) DisableApp(token string) (resp *Response, err error)

DisableApp function disables two factor auth using

func (*TwoFactorAuthServiceOp) DisableSms added in v0.2.0

func (s *TwoFactorAuthServiceOp) DisableSms(token string) (resp *Response, err error)

DisableSms function disables two factor auth using

func (*TwoFactorAuthServiceOp) EnableApp added in v0.2.0

func (s *TwoFactorAuthServiceOp) EnableApp(token string) (resp *Response, err error)

EnableApp function enables two factor auth using authenticatior app

func (*TwoFactorAuthServiceOp) EnableSms added in v0.2.0

func (s *TwoFactorAuthServiceOp) EnableSms(token string) (resp *Response, err error)

EnableSms function enables two factor auth using sms

func (*TwoFactorAuthServiceOp) ReceiveSms added in v0.2.0

func (s *TwoFactorAuthServiceOp) ReceiveSms() (resp *Response, err error)

ReceiveSms orders the auth service to issue an SMS token

func (*TwoFactorAuthServiceOp) SeedApp added in v0.2.0

func (s *TwoFactorAuthServiceOp) SeedApp() (otpURI string, resp *Response, err error)

SeedApp orders the auth service to issue a token via google authenticator

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"`
	DefaultOrganizationID string  `json:"default_organization_id,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:"emails,omitempty"`
	PhoneNumber           string  `json:"phone_number,omitempty"`
	URL                   string  `json:"href,omitempty"`
	VPN                   bool    `json:"vpn"`
}

User represents a Packet user

func (User) String

func (u User) String() string

type UserService

type UserService interface {
	List(*ListOptions) ([]User, *Response, error)
	Get(string, *GetOptions) (*User, *Response, error)
	Current() (*User, *Response, error)
}

UserService interface defines available user methods

type UserServiceOp

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

UserServiceOp implements UserService

func (*UserServiceOp) Current added in v0.2.0

func (s *UserServiceOp) Current() (*User, *Response, error)

Returns the user object for the currently logged-in user.

func (*UserServiceOp) Get

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

func (*UserServiceOp) List added in v0.2.0

func (s *UserServiceOp) List(listOpt *ListOptions) (users []User, resp *Response, err error)

Get method gets a user by userID

type VPNConfig added in v0.2.0

type VPNConfig struct {
	Config string `json:"config,omitempty"`
}

VPNConfig struct

type VPNService added in v0.2.0

type VPNService interface {
	Enable() (*Response, error)
	Disable() (*Response, error)
	Get(code string, getOpt *GetOptions) (*VPNConfig, *Response, error)
}

VPNService interface defines available VPN functions

type VPNServiceOp added in v0.2.0

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

VPNServiceOp implements VPNService

func (*VPNServiceOp) Disable added in v0.2.0

func (s *VPNServiceOp) Disable() (resp *Response, err error)

Disable VPN for current user

func (*VPNServiceOp) Enable added in v0.2.0

func (s *VPNServiceOp) Enable() (resp *Response, err error)

Enable VPN for current user

func (*VPNServiceOp) Get added in v0.2.0

func (s *VPNServiceOp) Get(code string, getOpt *GetOptions) (config *VPNConfig, resp *Response, err error)

Get returns the client vpn config for the currently logged-in user.

type VirtualNetwork added in v0.2.0

type VirtualNetwork struct {
	ID           string  `json:"id"`
	Description  string  `json:"description,omitempty"`
	VXLAN        int     `json:"vxlan,omitempty"`
	FacilityCode string  `json:"facility_code,omitempty"`
	CreatedAt    string  `json:"created_at,omitempty"`
	Href         string  `json:"href"`
	Project      Project `json:"assigned_to"`
}

type VirtualNetworkCreateRequest added in v0.2.0

type VirtualNetworkCreateRequest struct {
	ProjectID   string `json:"project_id"`
	Description string `json:"description"`
	Facility    string `json:"facility"`
}

type VirtualNetworkListResponse added in v0.2.0

type VirtualNetworkListResponse struct {
	VirtualNetworks []VirtualNetwork `json:"virtual_networks"`
}

type Volume

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

Volume represents a volume

func (Volume) String

func (v Volume) String() string

type VolumeAttachment added in v0.2.0

type VolumeAttachment struct {
	Href   string `json:"href"`
	ID     string `json:"id"`
	Volume Volume `json:"volume"`
	Device Device `json:"device"`
}

VolumeAttachment is a type from Packet API

type VolumeAttachmentService added in v0.2.0

type VolumeAttachmentService interface {
	Get(string, *GetOptions) (*VolumeAttachment, *Response, error)
	Create(string, string) (*VolumeAttachment, *Response, error)
	Delete(string) (*Response, error)
}

VolumeAttachmentService defines attachment methdods

type VolumeAttachmentServiceOp added in v0.2.0

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

VolumeAttachmentServiceOp implements VolumeService

func (*VolumeAttachmentServiceOp) Create added in v0.2.0

func (v *VolumeAttachmentServiceOp) Create(volumeID, deviceID string) (*VolumeAttachment, *Response, error)

Create Attachment, i.e. attach volume to a device

func (*VolumeAttachmentServiceOp) Delete added in v0.2.0

func (v *VolumeAttachmentServiceOp) Delete(attachmentID string) (*Response, error)

Delete deletes attachment by id

func (*VolumeAttachmentServiceOp) Get added in v0.2.0

func (v *VolumeAttachmentServiceOp) Get(attachmentID string, getOpt *GetOptions) (*VolumeAttachment, *Response, error)

Get gets attachment by id

type VolumeCreateRequest

type VolumeCreateRequest struct {
	BillingCycle     string            `json:"billing_cycle"`
	Description      string            `json:"description,omitempty"`
	Locked           bool              `json:"locked,omitempty"`
	Size             int               `json:"size"`
	PlanID           string            `json:"plan_id"`
	FacilityID       string            `json:"facility_id"`
	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 {
	List(string, *ListOptions) ([]Volume, *Response, error)
	Get(string, *GetOptions) (*Volume, *Response, error)
	Update(string, *VolumeUpdateRequest) (*Volume, *Response, error)
	Delete(string) (*Response, error)
	Create(*VolumeCreateRequest, string) (*Volume, *Response, error)
	Lock(string) (*Response, error)
	Unlock(string) (*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, projectID string) (*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, getOpt *GetOptions) (*Volume, *Response, error)

Get returns a volume by id

func (*VolumeServiceOp) List added in v0.2.0

func (v *VolumeServiceOp) List(projectID string, listOpt *ListOptions) (volumes []Volume, resp *Response, err error)

List returns the volumes for a project

func (*VolumeServiceOp) Lock added in v0.2.0

func (s *VolumeServiceOp) Lock(id string) (*Response, error)

Lock sets a volume to "locked"

func (*VolumeServiceOp) Unlock added in v0.2.0

func (s *VolumeServiceOp) Unlock(id string) (*Response, error)

Unlock sets a volume to "unlocked"

func (*VolumeServiceOp) Update

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

Update updates a volume

type VolumeUpdateRequest

type VolumeUpdateRequest struct {
	Description  *string `json:"description,omitempty"`
	PlanID       *string `json:"plan_id,omitempty"`
	Size         *int    `json:"size,omitempty"`
	BillingCycle *string `json:"billing_cycle,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