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 network
|
|
|
|
|
|
|
|
import (
|
|
|
|
triton "github.com/joyent/triton-go"
|
|
|
|
"github.com/joyent/triton-go/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
type NetworkClient struct {
|
|
|
|
Client *client.Client
|
|
|
|
}
|
|
|
|
|
|
|
|
func newNetworkClient(client *client.Client) *NetworkClient {
|
|
|
|
return &NetworkClient{
|
|
|
|
Client: client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewClient returns a new client for working with Network endpoints and
|
|
|
|
// resources within CloudAPI
|
|
|
|
func NewClient(config *triton.ClientConfig) (*NetworkClient, 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 newNetworkClient(client), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fabrics returns a FabricsClient used for accessing functions pertaining to
|
|
|
|
// Fabric functionality in the Triton API.
|
|
|
|
func (c *NetworkClient) Fabrics() *FabricsClient {
|
|
|
|
return &FabricsClient{c.Client}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Firewall returns a FirewallClient client used for accessing functions
|
|
|
|
// pertaining to firewall functionality in the Triton API.
|
|
|
|
func (c *NetworkClient) Firewall() *FirewallClient {
|
|
|
|
return &FirewallClient{c.Client}
|
|
|
|
}
|