2018-01-16 12:48:25 -05:00
|
|
|
//
|
|
|
|
// Copyright (c) 2018, Joyent, Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
//
|
|
|
|
|
2017-10-31 11:02:15 -04:00
|
|
|
package compute
|
|
|
|
|
|
|
|
import (
|
|
|
|
triton "github.com/joyent/triton-go"
|
|
|
|
"github.com/joyent/triton-go/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ComputeClient struct {
|
|
|
|
Client *client.Client
|
|
|
|
}
|
|
|
|
|
|
|
|
func newComputeClient(client *client.Client) *ComputeClient {
|
|
|
|
return &ComputeClient{
|
|
|
|
Client: client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewClient returns a new client for working with Compute endpoints and
|
|
|
|
// resources within CloudAPI
|
|
|
|
func NewClient(config *triton.ClientConfig) (*ComputeClient, error) {
|
|
|
|
// TODO: Utilize config interface within the function itself
|
|
|
|
client, err := client.New(config.TritonURL, config.MantaURL, config.AccountName, config.Signers...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return newComputeClient(client), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Datacenters returns a Compute client used for accessing functions pertaining
|
|
|
|
// to DataCenter functionality in the Triton API.
|
|
|
|
func (c *ComputeClient) Datacenters() *DataCentersClient {
|
|
|
|
return &DataCentersClient{c.Client}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Images returns a Compute client used for accessing functions pertaining to
|
|
|
|
// Images functionality in the Triton API.
|
|
|
|
func (c *ComputeClient) Images() *ImagesClient {
|
|
|
|
return &ImagesClient{c.Client}
|
|
|
|
}
|
|
|
|
|
2017-12-29 08:00:47 -05:00
|
|
|
// Machine returns a Compute client used for accessing functions pertaining to
|
2017-10-31 11:02:15 -04:00
|
|
|
// machine functionality in the Triton API.
|
|
|
|
func (c *ComputeClient) Instances() *InstancesClient {
|
|
|
|
return &InstancesClient{c.Client}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Packages returns a Compute client used for accessing functions pertaining to
|
|
|
|
// Packages functionality in the Triton API.
|
|
|
|
func (c *ComputeClient) Packages() *PackagesClient {
|
|
|
|
return &PackagesClient{c.Client}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Services returns a Compute client used for accessing functions pertaining to
|
|
|
|
// Services functionality in the Triton API.
|
|
|
|
func (c *ComputeClient) Services() *ServicesClient {
|
|
|
|
return &ServicesClient{c.Client}
|
|
|
|
}
|
2017-12-29 08:00:47 -05:00
|
|
|
|
|
|
|
// Snapshots returns a Compute client used for accessing functions pertaining to
|
|
|
|
// Snapshots functionality in the Triton API.
|
|
|
|
func (c *ComputeClient) Snapshots() *SnapshotsClient {
|
|
|
|
return &SnapshotsClient{c.Client}
|
|
|
|
}
|
2018-01-16 12:48:25 -05:00
|
|
|
|
|
|
|
// Snapshots returns a Compute client used for accessing functions pertaining to
|
|
|
|
// Snapshots functionality in the Triton API.
|
|
|
|
func (c *ComputeClient) Volumes() *VolumesClient {
|
|
|
|
return &VolumesClient{c.Client}
|
|
|
|
}
|