gosdc
gosdc
is a Go client for Joyent's SmartDataCenter
Table of Contents
Usage
To create a client
(*cloudapi.Client
),
you'll need a few things:
- your account ID
- the ID of the key associated with your account
- your private key material
- the cloud endpoint you want to use (for example
https://us-east-1.api.joyentcloud.com
)
Given these four pieces of information, you can initialize a client with the
following (N.B. error handling is glossed over in this example for the sake of
brevity):
package main
import (
"github.com/joyent/gocommon/client"
"github.com/joyent/gosdc/cloudapi"
"github.com/joyent/gosign/auth"
"io/ioutil"
)
func client(key, keyId, account, endpoint string) *cloudapi.Client {
keyData, _ := ioutil.ReadFile(key)
auth, _ := auth.NewAuth(account, string(keyData), "rsa-sha256")
creds := &auth.Credentials{
UserAuthentication: auth,
SdcKeyId: keyId,
SdcEndpoint: endpoint,
}
return cloudapi.New(client.NewClient(
endpoint,
cloudapi.DefaultAPIVersion,
creds,
&cloudapi.Logger
))
}
Examples
Projects using the gosdc API:
Resources
After creating a client, you can manipulate resources in the following ways:
Resource |
Create |
Read |
Update |
Delete |
Extra |
Datacenters |
|
GetDatacenter, ListDatacenters |
|
|
|
Firewall Rules |
CreateFirewallRule |
GetFirewallRule, ListFirewallRules, ListmachineFirewallRules |
UpdateFirewallRule, EnableFirewallRule, DisableFirewallRule |
DeleteFirewallRule |
|
Instrumentations |
CreateInstrumentation |
GetInstrumentation, ListInstrumentations, GetInstrumentationHeatmap, GetInstrumentationHeatmapDetails, GetInstrumentationValue |
|
DeleteInstrumentation |
DescribeAnalytics |
Keys |
CreateKey |
GetKey, ListKeys |
|
DeleteKey |
|
Machines |
CreateMachine |
GetMachine, ListMachines, ListFirewallRuleMachines |
RenameMachine, ResizeMachine |
DeleteMachine |
CountMachines, MachineAudit, StartMachine, StartMachineFromSnapshot, StopMachine, RebootMachine |
Machine (Images) |
CreateImageFromMachine |
GetImage, ListImages |
|
DeleteImage |
ExportImage |
Machine (Metadata) |
|
GetMachineMetadata |
UpdateMachineMetadata |
DeleteMachineMetadata, DeleteAllMachineMetadata |
|
Machine (Snapshots) |
CreateMachineSnapshot |
GetMachineSnapshot, ListMachineSnapshots |
|
DeleteMachineSnapshot |
|
Machine (Tags) |
|
GetMachineTag, ListMachineTags |
AddMachineTags, ReplaceMachineTags |
DeleteMachineTag, DeleteMachineTags |
EnableFirewallMachine, DisableFirewallMachine |
Networks |
|
GetNetwork, ListNetworks |
|
|
|
Packages |
|
GetPackage, ListPackages |
|
|
|
License
gosdc is licensed under the Mozilla Public License Version 2.0, a copy of which
is available at LICENSE