gosdc

package module
v0.0.0-...-8053c4d Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2016 License: MPL-2.0 Imports: 0 Imported by: 0

README

gosdc

wercker status

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:

  1. your account ID
  2. the ID of the key associated with your account
  3. your private key material
  4. 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

Documentation

Overview

Package gosdc enables Go programs to interact with the Joyent CloudAPI.

The gosdc package is structured as follow:

  • gosdc/cloudapi. This package interacts with the Cloud API (http://apidocs.joyent.com/cloudapi/).
  • gosdc/localservices. This package provides local services to be used for testing.

Licensed under the Mozilla Public License version 2.0

Copyright (c) Joyent Inc.

Directories

Path Synopsis
Package cloudapi interacts with the Cloud API (http://apidocs.joyent.com/cloudapi/).
Package cloudapi interacts with the Cloud API (http://apidocs.joyent.com/cloudapi/).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL