README

Ionburst SDK for Go Gitter

The Ionburst SDK for Go enables Golang developers to easily work with Ionburst Cloud and build ultra-secure and private storage into their applications.

Getting Started

Installation
$ go get gitlab.com/ionburst/ionburst-sdk-go
Configuration

The Ionburst SDK can get its configuration (ionburst_id, ionburst_key, ionburst_uri) from the following three files.

If ionburst_id and ionburst_key are not specified by environment variable, they are obtained from the credentials file.

If ionburst_uri is not specified in the Ionburst constructor, it'll check the credentials file.

Environment Variables
IONBURST_ID=IB******************
IONBURST_KEY=eW91aGF2ZXRvb211Y2h0aW1lb255b3VyaGFuZHMh
IONBURST_URI=https://api.example.ionburst.cloud/
Credentials file

~/.ionburst/credentials on Mac, Linux and BSD, and C:\Users\%USERNAME%\.ionburst\credentials on Windows

[example]
ionburst_id=IB******************
ionburst_key=eW91aGF2ZXRvb211Y2h0aW1lb255b3VyaGFuZHMh
ionburst_uri=https://api.example.ionburst.cloud/
ioncli

ioncli is a command line utility written using this SDK to perform basic operations.

Please click here to learn more.

Usage
Initialise
package client

import (
    ionburst "gitlab.com/ionburst/ionburst-sdk-go"
}

func main() {
    //Create a new client using the default config
    client, err := ionburst.NewClient() 

    //Create a client with implicit path and credentials profile name
    client, err := ionburst.NewClientPathAndProfile(configFilePath, credentialsProfileName, setDebugMode [true/false])

}
Upload Data
//get a readable stream
ioReader, _ := os.Open(FilePath)

client.Put(FileID, ioReader, classification)
//if classification is an empty string ("") it wont be passed

//Upload from a filepath instead
client.PutFromFile(FileID, FilePath, classification)
Download Data
ioReader, err := client.Get(FileID)

//Download to a filepath instead
err := client.GetToFile(FileID, OutputFilePath)

//Download and output the size of the downloaded content
ioReader, sizeOfContent, err := client.GetWithLen(FileID)
Delete Data
err := client.Delete(FileID)
Get Classifcations
classifications, _ := client.GetClassifications()
Usage in Deferred Mode
Upload Data Deferred
token, err := cli.PutDeferred(name, r, "")
if err != nil {
    t.Error(err)
    return
}
Download Data Deferred
token, err := cli.GetDeferred(name)
if err != nil {
    t.Error(err)
    return
}
Check Data Deferred
res, err = cli.CheckDeferred(tk)
if err != nil {
    t.Error(err)
    return
} else if !res.Success {
    t.Error(fmt.Sprintf("ERR: %s - %d", res.Message, res.Status))
    return
} else {
    ...
}
Fetch Data Deferred
ioReader, err := cli.FetchDeferred(tk)
if err != nil {
    t.Error(err)
    return
}

Getting Help

Please use the following community resources to get help. We use Gitlab issues to track bugs and feature requests.

Opening Issues

If you find a bug, or have an issue with the Ionburst SDK for Go we would like to hear about it. Check the existing issues and try to make sure your problem doesn’t already exist before opening a new issue. It’s helpful if you include the version of Ionburst SDK Go and the OS you’re using. Please include a stack trace and reduced repro case when appropriate, too.

The Gitlab issues are intended for bug reports and feature requests. For help and questions with using the Ionburst SDK for Go please make use of the resources listed in the Getting Help section. There are limited resources available for handling issues and by keeping the list of open issues clean we can respond in a timely manner.

SDK Change Log

The change log for the SDK can be found in the Gitlab Releases page

Contributors

A massive thanks to Craig Smith for developing this SDK.

Dependencies

Documentation

Index

Constants

View Source
const DefaultIonburstConfigPath = ".ionburst/credentials"
View Source
const DefaultIonburstCredentialsProfileName = "default"

Variables

View Source
var FileList = []string{
	"",
	".ion/config.json",
}

Functions

func FileExists

func FileExists(filename string) bool

func GetDefaultIonburstConfigPath

func GetDefaultIonburstConfigPath() string

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() (*Client, error)

func NewClientDebug

func NewClientDebug(debug bool) (*Client, error)

func NewClientPathAndProfile

func NewClientPathAndProfile(configPath string, credentialsProfile string, debug bool) (*Client, error)

func NewClientWithCredentials

func NewClientWithCredentials(uri string, ionburstID string, ionburstKey string, debug bool) (*Client, error)

func (*Client) CheckDeferred

func (cli *Client) CheckDeferred(token DeferredToken) (*models.WorkflowResult, error)

func (*Client) Delete

func (cli *Client) Delete(id string) error

func (*Client) FetchDeferred

func (cli *Client) FetchDeferred(token DeferredToken) (io.Reader, error)

func (*Client) Get

func (cli *Client) Get(id string) (io.Reader, error)

func (*Client) GetClassifications

func (cli *Client) GetClassifications() ([]string, error)

func (*Client) GetDeferred

func (cli *Client) GetDeferred(id string) (DeferredToken, error)

func (*Client) GetToFile

func (cli *Client) GetToFile(id string, file string) error

func (*Client) GetWithLen

func (cli *Client) GetWithLen(id string) (io.Reader, int64, error)

func (*Client) Put

func (cli *Client) Put(id string, reader io.Reader, classification string) error

func (*Client) PutDeferred

func (cli *Client) PutDeferred(id string, reader io.Reader, classification string) (DeferredToken, error)

func (*Client) PutFromFile

func (cli *Client) PutFromFile(id string, file string, classification string) error

type CredentialsProfile

type CredentialsProfile struct {
	IonburstURI string `json:"URI"`
	IonburstID  string `json:"ID"`
	IonburstKey string `json:"KEY"`
}

func NewCredentialsProfile

func NewCredentialsProfile(uri string, ionburstID string, ionburstKey string) *CredentialsProfile

type DeferredToken

type DeferredToken string

type IonConfig

type IonConfig struct {
	DefaultProfile string                         `json:"DefaultProfile,omitempty"`
	Profiles       map[string]*CredentialsProfile `json:"Profiles"`
	// contains filtered or unexported fields
}

func LoadIonConfig

func LoadIonConfig(cli *Client, configFile string) (*IonConfig, error)

func NewEmptyIonConfig

func NewEmptyIonConfig(cli *Client) *IonConfig

func NewIonConfig

func NewIonConfig(cli *Client, uri string, ionburstID string, ionburstKey string) *IonConfig

func NewIonConfigWithFilePaths

func NewIonConfigWithFilePaths(cli *Client, uri string, ionburstID string, ionburstKey string, configFile string) *IonConfig

func (*IonConfig) GetCredsProfile

func (conf *IonConfig) GetCredsProfile(name string) (*CredentialsProfile, error)

func (*IonConfig) GetDefaultCredsProfile

func (conf *IonConfig) GetDefaultCredsProfile() (*CredentialsProfile, error)

func (*IonConfig) LoadIniCreds

func (conf *IonConfig) LoadIniCreds() error

func (*IonConfig) RemoveCredsProfile

func (conf *IonConfig) RemoveCredsProfile(name string) error

func (*IonConfig) SaveConfig

func (conf *IonConfig) SaveConfig() error

func (*IonConfig) SaveConfigToFile

func (conf *IonConfig) SaveConfigToFile(file string) error

func (*IonConfig) SetDefaultProfile

func (conf *IonConfig) SetDefaultProfile(profileName string) error

func (*IonConfig) UpsertCredsProfile

func (conf *IonConfig) UpsertCredsProfile(name string, uri string, ionburstID string, ionburstKey string) *CredentialsProfile

Directories

Path Synopsis