deps: Update github.com/joyent/triton-go
This commit is contained in:
parent
362ad5d7fa
commit
01714eceb5
|
@ -5,8 +5,9 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/errwrap"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/hashicorp/errwrap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AccountsClient struct {
|
type AccountsClient struct {
|
||||||
|
@ -40,7 +41,8 @@ type Account struct {
|
||||||
type GetAccountInput struct{}
|
type GetAccountInput struct{}
|
||||||
|
|
||||||
func (client *AccountsClient) GetAccount(input *GetAccountInput) (*Account, error) {
|
func (client *AccountsClient) GetAccount(input *GetAccountInput) (*Account, error) {
|
||||||
respReader, err := client.executeRequest(http.MethodGet, "/my", nil)
|
path := fmt.Sprintf("/%s", client.accountName)
|
||||||
|
respReader, err := client.executeRequest(http.MethodGet, path, nil)
|
||||||
if respReader != nil {
|
if respReader != nil {
|
||||||
defer respReader.Close()
|
defer respReader.Close()
|
||||||
}
|
}
|
||||||
|
@ -58,17 +60,17 @@ func (client *AccountsClient) GetAccount(input *GetAccountInput) (*Account, erro
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateAccountInput struct {
|
type UpdateAccountInput struct {
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email,omitempty"`
|
||||||
CompanyName string `json:"companyName,omitempty"`
|
CompanyName string `json:"companyName,omitempty"`
|
||||||
FirstName string `json:"firstName,omitempty"`
|
FirstName string `json:"firstName,omitempty"`
|
||||||
LastName string `json:"lastName,omitempty"`
|
LastName string `json:"lastName,omitempty"`
|
||||||
Address string `json:"address,omitempty"`
|
Address string `json:"address,omitempty"`
|
||||||
PostalCode string `json:"postalCode,omitempty"`
|
PostalCode string `json:"postalCode,omitempty"`
|
||||||
City string `json:"city,omitempty"`
|
City string `json:"city,omitempty"`
|
||||||
State string `json:"state,omitempty"`
|
State string `json:"state,omitempty"`
|
||||||
Country string `json:"country,omitempty"`
|
Country string `json:"country,omitempty"`
|
||||||
Phone string `json:"phone,omitempty"`
|
Phone string `json:"phone,omitempty"`
|
||||||
TritonCNSEnabled bool `json:"triton_cns_enabled,omitempty"`
|
TritonCNSEnabled bool `json:"triton_cns_enabled,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateAccount updates your account details with the given parameters.
|
// UpdateAccount updates your account details with the given parameters.
|
||||||
|
|
|
@ -2,6 +2,7 @@ package triton
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -45,16 +46,7 @@ func NewClient(endpoint string, accountName string, signers ...authentication.Si
|
||||||
}
|
}
|
||||||
|
|
||||||
httpClient := &http.Client{
|
httpClient := &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: httpTransport(false),
|
||||||
Proxy: http.ProxyFromEnvironment,
|
|
||||||
Dial: (&net.Dialer{
|
|
||||||
Timeout: 30 * time.Second,
|
|
||||||
KeepAlive: 30 * time.Second,
|
|
||||||
}).Dial,
|
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
|
||||||
DisableKeepAlives: true,
|
|
||||||
MaxIdleConnsPerHost: -1,
|
|
||||||
},
|
|
||||||
CheckRedirect: doNotFollowRedirects,
|
CheckRedirect: doNotFollowRedirects,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +67,34 @@ func NewClient(endpoint string, accountName string, signers ...authentication.Si
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InsecureSkipTLSVerify turns off TLS verification for the client connection. This
|
||||||
|
// allows connection to an endpoint with a certificate which was signed by a non-
|
||||||
|
// trusted CA, such as self-signed certificates. This can be useful when connecting
|
||||||
|
// to temporary Triton installations such as Triton Cloud-On-A-Laptop.
|
||||||
|
func (c *Client) InsecureSkipTLSVerify() {
|
||||||
|
if c.client == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.client.HTTPClient.Transport = httpTransport(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func httpTransport(insecureSkipTLSVerify bool) *http.Transport {
|
||||||
|
return &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
Dial: (&net.Dialer{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
}).Dial,
|
||||||
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
|
DisableKeepAlives: true,
|
||||||
|
MaxIdleConnsPerHost: -1,
|
||||||
|
TLSClientConfig: &tls.Config{
|
||||||
|
InsecureSkipVerify: insecureSkipTLSVerify,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func doNotFollowRedirects(*http.Request, []*http.Request) error {
|
func doNotFollowRedirects(*http.Request, []*http.Request) error {
|
||||||
return http.ErrUseLastResponse
|
return http.ErrUseLastResponse
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,8 @@ type DataCenter struct {
|
||||||
type ListDataCentersInput struct{}
|
type ListDataCentersInput struct{}
|
||||||
|
|
||||||
func (client *DataCentersClient) ListDataCenters(*ListDataCentersInput) ([]*DataCenter, error) {
|
func (client *DataCentersClient) ListDataCenters(*ListDataCentersInput) ([]*DataCenter, error) {
|
||||||
respReader, err := client.executeRequest(http.MethodGet, "/my/datacenters", nil)
|
path := fmt.Sprintf("/%s/datacenters", client.accountName)
|
||||||
|
respReader, err := client.executeRequest(http.MethodGet, path, nil)
|
||||||
if respReader != nil {
|
if respReader != nil {
|
||||||
defer respReader.Close()
|
defer respReader.Close()
|
||||||
}
|
}
|
||||||
|
@ -68,7 +69,8 @@ type GetDataCenterInput struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *DataCentersClient) GetDataCenter(input *GetDataCenterInput) (*DataCenter, error) {
|
func (client *DataCentersClient) GetDataCenter(input *GetDataCenterInput) (*DataCenter, error) {
|
||||||
resp, err := client.executeRequestRaw(http.MethodGet, fmt.Sprintf("/my/datacenters/%s", input.Name), nil)
|
path := fmt.Sprintf("/%s/datacenters/%s", client.accountName, input.Name)
|
||||||
|
resp, err := client.executeRequestRaw(http.MethodGet, path, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf("Error executing GetDatacenter request: {{err}}", err)
|
return nil, errwrap.Wrapf("Error executing GetDatacenter request: {{err}}", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@ type FabricVLAN struct {
|
||||||
type ListFabricVLANsInput struct{}
|
type ListFabricVLANsInput struct{}
|
||||||
|
|
||||||
func (client *FabricsClient) ListFabricVLANs(*ListFabricVLANsInput) ([]*FabricVLAN, error) {
|
func (client *FabricsClient) ListFabricVLANs(*ListFabricVLANsInput) ([]*FabricVLAN, error) {
|
||||||
respReader, err := client.executeRequest(http.MethodGet, "/my/fabrics/default/vlans", nil)
|
path := fmt.Sprintf("/%s/fabrics/default/vlans", client.accountName)
|
||||||
|
respReader, err := client.executeRequest(http.MethodGet, path, nil)
|
||||||
if respReader != nil {
|
if respReader != nil {
|
||||||
defer respReader.Close()
|
defer respReader.Close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ type FirewallRule struct {
|
||||||
type ListFirewallRulesInput struct{}
|
type ListFirewallRulesInput struct{}
|
||||||
|
|
||||||
func (client *FirewallClient) ListFirewallRules(*ListFirewallRulesInput) ([]*FirewallRule, error) {
|
func (client *FirewallClient) ListFirewallRules(*ListFirewallRulesInput) ([]*FirewallRule, error) {
|
||||||
respReader, err := client.executeRequest(http.MethodGet, "/my/fwrules", nil)
|
path := fmt.Sprintf("/%s/fwrules", client.accountName)
|
||||||
|
respReader, err := client.executeRequest(http.MethodGet, path, nil)
|
||||||
if respReader != nil {
|
if respReader != nil {
|
||||||
defer respReader.Close()
|
defer respReader.Close()
|
||||||
}
|
}
|
||||||
|
@ -194,7 +195,8 @@ type ListMachineFirewallRulesInput struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FirewallClient) ListMachineFirewallRules(input *ListMachineFirewallRulesInput) ([]*FirewallRule, error) {
|
func (client *FirewallClient) ListMachineFirewallRules(input *ListMachineFirewallRulesInput) ([]*FirewallRule, error) {
|
||||||
respReader, err := client.executeRequest(http.MethodGet, fmt.Sprintf("/my/machines/%s/firewallrules", input.MachineID), nil)
|
path := fmt.Sprintf("/%s/machines/%s/firewallrules", client.accountName, input.MachineID)
|
||||||
|
respReader, err := client.executeRequest(http.MethodGet, path, nil)
|
||||||
if respReader != nil {
|
if respReader != nil {
|
||||||
defer respReader.Close()
|
defer respReader.Close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,8 @@ type Image struct {
|
||||||
type ListImagesInput struct{}
|
type ListImagesInput struct{}
|
||||||
|
|
||||||
func (client *ImagesClient) ListImages(*ListImagesInput) ([]*Image, error) {
|
func (client *ImagesClient) ListImages(*ListImagesInput) ([]*Image, error) {
|
||||||
respReader, err := client.executeRequest(http.MethodGet, "/my/images", nil)
|
path := fmt.Sprintf("/%s/images", client.accountName)
|
||||||
|
respReader, err := client.executeRequest(http.MethodGet, path, nil)
|
||||||
if respReader != nil {
|
if respReader != nil {
|
||||||
defer respReader.Close()
|
defer respReader.Close()
|
||||||
}
|
}
|
||||||
|
@ -148,7 +149,7 @@ type CreateImageFromMachineInput struct {
|
||||||
HomePage string `json:"homepage,omitempty"`
|
HomePage string `json:"homepage,omitempty"`
|
||||||
EULA string `json:"eula,omitempty"`
|
EULA string `json:"eula,omitempty"`
|
||||||
ACL []string `json:"acl,omitempty"`
|
ACL []string `json:"acl,omitempty"`
|
||||||
tags map[string]string `json:"tags,omitempty"`
|
Tags map[string]string `json:"tags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *ImagesClient) CreateImageFromMachine(input *CreateImageFromMachineInput) (*Image, error) {
|
func (client *ImagesClient) CreateImageFromMachine(input *CreateImageFromMachineInput) (*Image, error) {
|
||||||
|
@ -178,7 +179,7 @@ type UpdateImageInput struct {
|
||||||
HomePage string `json:"homepage,omitempty"`
|
HomePage string `json:"homepage,omitempty"`
|
||||||
EULA string `json:"eula,omitempty"`
|
EULA string `json:"eula,omitempty"`
|
||||||
ACL []string `json:"acl,omitempty"`
|
ACL []string `json:"acl,omitempty"`
|
||||||
tags map[string]string `json:"tags,omitempty"`
|
Tags map[string]string `json:"tags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *ImagesClient) UpdateImage(input *UpdateImageInput) (*Image, error) {
|
func (client *ImagesClient) UpdateImage(input *UpdateImageInput) (*Image, error) {
|
||||||
|
|
|
@ -35,7 +35,8 @@ type ListKeysInput struct{}
|
||||||
// ListKeys lists all public keys we have on record for the specified
|
// ListKeys lists all public keys we have on record for the specified
|
||||||
// account.
|
// account.
|
||||||
func (client *KeysClient) ListKeys(*ListKeysInput) ([]*Key, error) {
|
func (client *KeysClient) ListKeys(*ListKeysInput) ([]*Key, error) {
|
||||||
respReader, err := client.executeRequest(http.MethodGet, "/my/keys", nil)
|
path := fmt.Sprintf("/%s/keys")
|
||||||
|
respReader, err := client.executeRequest(http.MethodGet, path, nil)
|
||||||
if respReader != nil {
|
if respReader != nil {
|
||||||
defer respReader.Close()
|
defer respReader.Close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ func (client *MachinesClient) GetMachine(input *GetMachineInput) (*Machine, erro
|
||||||
if response != nil {
|
if response != nil {
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
}
|
}
|
||||||
if response.StatusCode == http.StatusNotFound {
|
if response.StatusCode == http.StatusNotFound || response.StatusCode == http.StatusGone {
|
||||||
return nil, &TritonError{
|
return nil, &TritonError{
|
||||||
Code: "ResourceNotFound",
|
Code: "ResourceNotFound",
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,8 @@ func (input *CreateMachineInput) toAPI() map[string]interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MachinesClient) CreateMachine(input *CreateMachineInput) (*Machine, error) {
|
func (client *MachinesClient) CreateMachine(input *CreateMachineInput) (*Machine, error) {
|
||||||
respReader, err := client.executeRequest(http.MethodPost, "/my/machines", input.toAPI())
|
path := fmt.Sprintf("/%s/machines", client.accountName)
|
||||||
|
respReader, err := client.executeRequest(http.MethodPost, path, input.toAPI())
|
||||||
if respReader != nil {
|
if respReader != nil {
|
||||||
defer respReader.Close()
|
defer respReader.Close()
|
||||||
}
|
}
|
||||||
|
@ -501,7 +502,8 @@ type ListNICsInput struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MachinesClient) ListNICs(input *ListNICsInput) ([]*NIC, error) {
|
func (client *MachinesClient) ListNICs(input *ListNICsInput) ([]*NIC, error) {
|
||||||
respReader, err := client.executeRequest(http.MethodGet, fmt.Sprintf("/my/machines/%s/nics", input.MachineID), nil)
|
path := fmt.Sprintf("/%s/machines/%s/nics", client.accountName, input.MachineID)
|
||||||
|
respReader, err := client.executeRequest(http.MethodGet, path, nil)
|
||||||
if respReader != nil {
|
if respReader != nil {
|
||||||
defer respReader.Close()
|
defer respReader.Close()
|
||||||
}
|
}
|
||||||
|
@ -560,6 +562,48 @@ func (client *MachinesClient) RemoveNIC(input *RemoveNICInput) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StopMachineInput struct {
|
||||||
|
MachineID string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (client *MachinesClient) StopMachine(input *StopMachineInput) error {
|
||||||
|
path := fmt.Sprintf("/%s/machines/%s", client.accountName, input.MachineID)
|
||||||
|
|
||||||
|
params := &url.Values{}
|
||||||
|
params.Set("action", "stop")
|
||||||
|
|
||||||
|
respReader, err := client.executeRequestURIParams(http.MethodPost, path, nil, params)
|
||||||
|
if respReader != nil {
|
||||||
|
defer respReader.Close()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return errwrap.Wrapf("Error executing StopMachine request: {{err}}", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type StartMachineInput struct {
|
||||||
|
MachineID string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (client *MachinesClient) StartMachine(input *StartMachineInput) error {
|
||||||
|
path := fmt.Sprintf("/%s/machines/%s", client.accountName, input.MachineID)
|
||||||
|
|
||||||
|
params := &url.Values{}
|
||||||
|
params.Set("action", "start")
|
||||||
|
|
||||||
|
respReader, err := client.executeRequestURIParams(http.MethodPost, path, nil, params)
|
||||||
|
if respReader != nil {
|
||||||
|
defer respReader.Close()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return errwrap.Wrapf("Error executing StartMachine request: {{err}}", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var reservedMachineCNSTags = map[string]struct{}{
|
var reservedMachineCNSTags = map[string]struct{}{
|
||||||
machineCNSTagDisable: {},
|
machineCNSTagDisable: {},
|
||||||
machineCNSTagReversePTR: {},
|
machineCNSTagReversePTR: {},
|
||||||
|
|
|
@ -36,7 +36,8 @@ type Network struct {
|
||||||
type ListNetworksInput struct{}
|
type ListNetworksInput struct{}
|
||||||
|
|
||||||
func (client *NetworksClient) ListNetworks(*ListNetworksInput) ([]*Network, error) {
|
func (client *NetworksClient) ListNetworks(*ListNetworksInput) ([]*Network, error) {
|
||||||
respReader, err := client.executeRequest(http.MethodGet, "/my/networks", nil)
|
path := fmt.Sprintf("/%s/networks", client.accountName)
|
||||||
|
respReader, err := client.executeRequest(http.MethodGet, path, nil)
|
||||||
if respReader != nil {
|
if respReader != nil {
|
||||||
defer respReader.Close()
|
defer respReader.Close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -2341,16 +2341,16 @@
|
||||||
"revisionTime": "2016-06-16T18:50:15Z"
|
"revisionTime": "2016-06-16T18:50:15Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "2HimxaJVVp2QDVQ0570L71Zd5s4=",
|
"checksumSHA1": "XsjyaC6eTHUy/n0iuR46TZcgAK8=",
|
||||||
"path": "github.com/joyent/triton-go",
|
"path": "github.com/joyent/triton-go",
|
||||||
"revision": "5db9e2b6a4c1f7ffd2a7e7aa625f42dba956608c",
|
"revision": "c73729fd38522591909a371c8180ca7090a59ab9",
|
||||||
"revisionTime": "2017-04-12T23:23:58Z"
|
"revisionTime": "2017-04-28T18:47:44Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "QzUqkCSn/ZHyIK346xb9V6EBw9U=",
|
"checksumSHA1": "QzUqkCSn/ZHyIK346xb9V6EBw9U=",
|
||||||
"path": "github.com/joyent/triton-go/authentication",
|
"path": "github.com/joyent/triton-go/authentication",
|
||||||
"revision": "66b31a94af28a65e902423879a2820ea34b773fb",
|
"revision": "c73729fd38522591909a371c8180ca7090a59ab9",
|
||||||
"revisionTime": "2017-03-31T18:12:29Z"
|
"revisionTime": "2017-04-28T18:47:44Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "YhQcOsGx8r2S/jkJ0Qt4cZ5BLCU=",
|
"checksumSHA1": "YhQcOsGx8r2S/jkJ0Qt4cZ5BLCU=",
|
||||||
|
|
Loading…
Reference in New Issue