packngo

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2018 License: BSD-3-Clause, MIT Imports: 14 Imported by: 0

README

packngo

Packet Go Api Client

Committing

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

Usage

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

If you want to use it in your Go code, you can 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.

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 all the tests, you can do

$ PACKNGO_TEST_ACTUAL_API=1 go test -v -parallel 8

It's also useful to run only single acceptance test at a time:

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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.1.1

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

type AddressStruct added in v0.1.1

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

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

type AvailableRequest added in v0.1.1

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

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

type AvailableResponse added in v0.1.1

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

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

type BackToL3Request added in v0.1.1

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

type BillingAddress added in v0.1.1

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.1.1

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

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
	Organizations          OrganizationService
	// 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)

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.1.1

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) 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"`
	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     []*ProvisionEvent      `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"`
}

Device represents a Packet device

func (Device) String

func (d Device) String() string

type DeviceActionRequest

type DeviceActionRequest struct {
	Type string `json:"type"`
	OS   string `json:"operating_system,omitempty"`
}

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"`
	ProjectSSHKeys        []string   `json:"project_ssh_keys,omitempty"`
	UserSSHKeys           []string   `json:"user_ssh_keys,omitempty"`
}

DeviceCreateRequest type used to create a Packet device

func (DeviceCreateRequest) String

func (d DeviceCreateRequest) String() string

type DeviceIPService added in v0.1.1

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

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

type DeviceIPServiceOp added in v0.1.1

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

DeviceIPServiceOp is interface for IP-address assignment methods.

func (*DeviceIPServiceOp) Assign added in v0.1.1

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.1.1

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

Get returns assignment by ID.

func (*DeviceIPServiceOp) Unassign added in v0.1.1

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.1.1

type DevicePortService interface {
	Assign(*PortAssignRequest) (*Port, *Response, error)
	Unassign(*PortAssignRequest) (*Port, *Response, error)
	Bond(*BondRequest) (*Port, *Response, error)
	Disbond(*DisbondRequest) (*Port, *Response, error)
	PortToLayerTwo(string) (*Port, *Response, error)
	PortToLayerThree(string) (*Port, *Response, error)
	DeviceToLayerTwo(string) (*Device, error)
	DeviceToLayerThree(string) (*Device, error)
	DeviceNetworkType(string) (NetworkType, 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.1.1

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

func (*DevicePortServiceOp) Assign added in v0.1.1

func (*DevicePortServiceOp) Bond added in v0.1.1

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

func (*DevicePortServiceOp) DeviceNetworkType added in v0.1.1

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

func (*DevicePortServiceOp) DeviceToLayerThree added in v0.1.1

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

func (*DevicePortServiceOp) DeviceToLayerTwo added in v0.1.1

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

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

func (*DevicePortServiceOp) Disbond added in v0.1.1

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

func (*DevicePortServiceOp) GetBondPort added in v0.1.1

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

func (*DevicePortServiceOp) GetPortByName added in v0.1.1

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

func (*DevicePortServiceOp) PortToLayerThree added in v0.1.1

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

func (*DevicePortServiceOp) PortToLayerTwo added in v0.1.1

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

func (*DevicePortServiceOp) Unassign added in v0.1.1

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

type DeviceService

type DeviceService interface {
	List(ProjectID string) ([]Device, *Response, error)
	Get(string) (*Device, *Response, error)
	GetExtra(deviceID string, includes, excludes []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)
	Reinstall(string, string) (*Response, error)
	Rescue(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) GetExtra added in v0.1.1

func (s *DeviceServiceOp) GetExtra(deviceID string, includes, excludes []string) (*Device, *Response, error)

GetExtra returns a device by id. Specifying either includes/excludes provides more or less desired detailed information about resources which would otherwise be represented with an href link

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) Reinstall added in v0.1.1

func (s *DeviceServiceOp) Reinstall(deviceID, os string) (*Response, error)

Reinstall reinstalls an OS on a device

func (*DeviceServiceOp) Rescue added in v0.1.1

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

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 DisbondRequest added in v0.1.1

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 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"`
	SingleError string   `json:"error"`
}

ErrorResponse is the http response used on errors

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 Href added in v0.1.1

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

Href is an API link

type IPAddressAssignment added in v0.1.1

type IPAddressAssignment struct {
	AssignedTo Href `json:"assigned_to"`
	// contains filtered or unexported fields
}

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

func (IPAddressAssignment) String added in v0.1.1

func (i IPAddressAssignment) String() string

type IPAddressReservation added in v0.1.1

type IPAddressReservation struct {
	Assignments []Href   `json:"assignments"`
	Facility    Facility `json:"facility,omitempty"`
	Available   string   `json:"available"`
	Addon       bool     `json:"addon"`
	Bill        bool     `json:"bill"`
	// contains filtered or unexported fields
}

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

func (IPAddressReservation) String added in v0.1.1

func (i IPAddressReservation) String() string

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 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 NetworkType added in v0.1.1

type NetworkType int
const (
	NetworkL3 NetworkType = iota
	NetworkHybrid
	NetworkL2Bonded
	NetworkL2Individual
	NetworkUnknown
)

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

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.1.1

func (o Organization) String() string

type OrganizationCreateRequest added in v0.1.1

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.1.1

func (o OrganizationCreateRequest) String() string

type OrganizationService added in v0.1.1

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

OrganizationService interface defines available organization methods

type OrganizationServiceOp added in v0.1.1

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

OrganizationServiceOp implements OrganizationService

func (*OrganizationServiceOp) Create added in v0.1.1

Create creates a new organization

func (*OrganizationServiceOp) Delete added in v0.1.1

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

Delete deletes an organizationID

func (*OrganizationServiceOp) Get added in v0.1.1

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

Get returns a organization by id

func (*OrganizationServiceOp) List added in v0.1.1

List returns the user's organizations

func (*OrganizationServiceOp) ListPaymentMethods added in v0.1.1

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

ListPaymentMethods returns PaymentMethods for an organization

func (*OrganizationServiceOp) Update added in v0.1.1

Update updates an organization

type OrganizationUpdateRequest added in v0.1.1

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

OrganizationUpdateRequest type used to update a Packet organization

func (OrganizationUpdateRequest) String added in v0.1.1

func (o OrganizationUpdateRequest) String() string

type PaymentMethod added in v0.1.1

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.1.1

func (pm PaymentMethod) String() string

type PaymentMethodCreateRequest added in v0.1.1

type PaymentMethodCreateRequest struct {
	Name           string `json:"name"`
	Nonce          string `json:"name"`
	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.1.1

func (pm PaymentMethodCreateRequest) String() string

type PaymentMethodService added in v0.1.1

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

ProjectService interface defines available project methods

type PaymentMethodServiceOp added in v0.1.1

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

PaymentMethodServiceOp implements PaymentMethodService

type PaymentMethodUpdateRequest added in v0.1.1

type PaymentMethodUpdateRequest struct {
	ID             string `json:"id"`
	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.1.1

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"`
}

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 Port added in v0.1.1

type Port struct {
	ID                      string           `json:"id"`
	Type                    string           `json:"type"`
	Name                    string           `json:"name"`
	Data                    PortData         `json:"data"`
	AttachedVirtualNetworks []VirtualNetwork `json:"virtual_networks"`
}

type PortAssignRequest added in v0.1.1

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

type PortData added in v0.1.1

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

type PriceMap added in v0.1.1

type PriceMap map[string]map[string]float64

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

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"`
	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"`
}

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:"-"`
}

ProjectCreateRequest type used to create a Packet project

func (ProjectCreateRequest) String

func (p ProjectCreateRequest) String() string

type ProjectIPService added in v0.1.1

type ProjectIPService interface {
	Get(reservationID string) (*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.1.1

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

ProjectIPServiceOp is interface for IP assignment methods.

func (*ProjectIPServiceOp) AvailableAddresses added in v0.1.1

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.1.1

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

Get returns reservation by ID.

func (*ProjectIPServiceOp) List added in v0.1.1

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.1.1

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

Remove removes an IP reservation from the project.

func (*ProjectIPServiceOp) Request added in v0.1.1

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() ([]Project, *Response, error)
	Get(string) (*Project, *Response, error)
	Create(*ProjectCreateRequest) (*Project, *Response, error)
	Update(*ProjectUpdateRequest) (*Project, *Response, error)
	Delete(string) (*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) ListVolumes

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

ListVolumes 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"`
	PaymentMethodID string `json:"payment_method_id,omitempty"`
}

ProjectUpdateRequest type used to update a Packet project

func (ProjectUpdateRequest) String

func (p ProjectUpdateRequest) String() string

type ProjectVirtualNetworkService added in v0.1.1

type ProjectVirtualNetworkService interface {
	List(projectID string) (*VirtualNetworkListResponse, *Response, error)
	Create(*VirtualNetworkCreateRequest) (*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.1.1

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

func (*ProjectVirtualNetworkServiceOp) Create added in v0.1.1

func (*ProjectVirtualNetworkServiceOp) Delete added in v0.1.1

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

func (*ProjectVirtualNetworkServiceOp) List added in v0.1.1

type ProvisionEvent added in v0.1.1

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

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) (*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) ProjectList added in v0.1.1

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

ProjectList lists ssh keys of a project

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,omitempty"`
	Key   string `json:"key,omitempty"`
}

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 SpotMarketService added in v0.1.1

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

SpotMarketService expooses Spot Market methods

type SpotMarketServiceOp added in v0.1.1

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

SpotMarketServiceOp implements SpotMarketService

func (*SpotMarketServiceOp) Prices added in v0.1.1

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 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"`
}

User represents a Packet user

func (User) String

func (u User) String() string

type UserService

type UserService interface {
	Get(string) (*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.1.1

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) (*User, *Response, error)

Get method gets a user by userID

type VirtualNetwork added in v0.1.1

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"`
}

type VirtualNetworkCreateRequest added in v0.1.1

type VirtualNetworkCreateRequest struct {
	ProjectID   string `json:"project_id"`
	Description string `json:"description"`
	Facility    string `json:"facility"`
	VXLAN       int    `json:"vxlan"`
	VLAN        int    `json:"vlan"`
}

type VirtualNetworkCreateResponse added in v0.1.1

type VirtualNetworkCreateResponse struct {
	VirtualNetwork VirtualNetwork `json:"virtual_networks"`
}

type VirtualNetworkListResponse added in v0.1.1

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

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      []*VolumeAttachment `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 VolumeAttachment added in v0.1.1

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.1.1

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

VolumeAttachmentService defines attachment methdods

type VolumeAttachmentServiceOp added in v0.1.1

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

VolumeAttachmentServiceOp implements VolumeService

func (*VolumeAttachmentServiceOp) Create added in v0.1.1

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.1.1

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

Delete deletes attachment by id

func (*VolumeAttachmentServiceOp) Get added in v0.1.1

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

Get gets attachment by id

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, string) (*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, 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) (*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