manta

package
v0.0.0-...-41c8bc3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2016 License: MPL-2.0 Imports: 10 Imported by: 69

Documentation

Overview

The gomanta/manta package interacts with the Manta API (http://apidocs.joyent.com/manta/api.html).

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/.

Copyright (c) 2016 Joyent Inc. Written by Daniele Stroppa <daniele.stroppa@joyent.com>

Index

Constants

View Source
const (
	// The default version of the Manta API to use
	DefaultAPIVersion = "7.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides a means to access Joyent Manta

func New

func New(client client.Client) *Client

New creates a new Client.

func (*Client) AddJobInputs

func (c *Client) AddJobInputs(jobId string, jobInputs io.Reader) error

Submits inputs to an already created job. See API docs: http://apidocs.joyent.com/manta/api.html#AddJobInputs

func (*Client) CancelJob

func (c *Client) CancelJob(jobId string) error

This cancels a job from doing any further work. Cancellation is asynchronous and "best effort"; there is no guarantee the job will actually stop See API docs: http://apidocs.joyent.com/manta/api.html#CancelJob

func (*Client) CreateJob

func (c *Client) CreateJob(opts CreateJobOpts) (string, error)

Creates a job with the given options. See API docs: http://apidocs.joyent.com/manta/api.html#CreateJob

func (*Client) DeleteDirectory

func (c *Client) DeleteDirectory(path string) error

Deletes the specified directory. Directory must be empty. See API docs: http://apidocs.joyent.com/manta/api.html#DeleteDirectory

func (*Client) DeleteObject

func (c *Client) DeleteObject(path, objectName string) error

Deletes the specified object from the specified location. See API docs: http://apidocs.joyent.com/manta/api.html#DeleteObject

func (*Client) EndJobInputs

func (c *Client) EndJobInputs(jobId string) error

This closes input for a job, and finalize the job. See API docs: http://apidocs.joyent.com/manta/api.html#EndJobInput

func (*Client) GetJob

func (c *Client) GetJob(jobId string) (Job, error)

Gets the high-level job container object for a given job. See API docs: http://apidocs.joyent.com/manta/api.html#GetJob

func (*Client) GetJobErrors

func (c *Client) GetJobErrors(jobId string) ([]JobError, error)

Returns the current "live" set of errors from a given job. See API docs: http://apidocs.joyent.com/manta/api.html#GetJobErrors

func (*Client) GetJobFailures

func (c *Client) GetJobFailures(jobId string) (interface{}, error)

Returns the current "live" set of failures from a given job. See API docs: http://apidocs.joyent.com/manta/api.html#GetJobFailures

func (*Client) GetJobInput

func (c *Client) GetJobInput(jobId string) (string, error)

Returns the submitted input objects for a given job, available while the job is running. See API docs: http://apidocs.joyent.com/manta/api.html#GetJobInput

func (*Client) GetJobOutput

func (c *Client) GetJobOutput(jobId string) (string, error)

Returns the current "live" set of outputs from a given job. See API docs: http://apidocs.joyent.com/manta/api.html#GetJobOutput

func (*Client) GetObject

func (c *Client) GetObject(path, objectName string) ([]byte, error)

Retrieves the specified object from the specified location. See API docs: http://apidocs.joyent.com/manta/api.html#GetObject

func (*Client) ListDirectory

func (c *Client) ListDirectory(directory string, opts ListDirectoryOpts) ([]Entry, error)

Returns the content of the specified directory, using the specified options. See API docs: http://apidocs.joyent.com/manta/api.html#ListDirectory

func (*Client) ListJobs

func (c *Client) ListJobs(liveOnly bool) ([]Entry, error)

Returns the list of jobs. Note you can filter the set of jobs down to only live jobs by setting the liveOnly flag. See API docs: http://apidocs.joyent.com/manta/api.html#ListJobs

func (*Client) PutDirectory

func (c *Client) PutDirectory(path string) error

Creates a directory at the specified path. Any parent directory must exist. See API docs: http://apidocs.joyent.com/manta/api.html#PutDirectory

func (*Client) PutObject

func (c *Client) PutObject(path, objectName string, object []byte) error

Creates an object at the specified path. Any parent directory must exist. See API docs: http://apidocs.joyent.com/manta/api.html#PutObject

func (c *Client) PutSnapLink(path, linkName, location string) error

Creates a link (similar to a Unix hard link) from location to path/linkName. See API docs: http://apidocs.joyent.com/manta/api.html#PutSnapLink

func (*Client) SignURL

func (c *Client) SignURL(path string, expires time.Time) (string, error)

Returns a signed URL to retrieve the object at path.

type CreateJobOpts

type CreateJobOpts struct {
	Name   string  `json:"name,omitempty"` // Job Name (optional)
	Phases []Phase `json:"phases"`         // Tasks to execute as part of this job
}

CreateJobOpts represent the option that can be specified when creating a job.

type Entry

type Entry struct {
	Name  string `json:"name"`           // Entry name
	Etag  string `json:"etag,omitempty"` // If type is 'object', object UUID
	Size  int    `json:"size,omitempty"` // If type is 'object', object size (content-length)
	Type  string `json:"type"`           // Entry type, one of 'directory' or 'object'
	Mtime string `json:"mtime"`          // ISO8601 timestamp of the last update
}

Entry represents an object stored in Manta, either a file or a directory

type Job

type Job struct {
	Id                 string      // Job unique identifier
	Name               string      `json:"name,omitempty"` // Job Name
	State              string      // Job state
	Cancelled          bool        // Whether the job has been cancelled or not
	InputDone          bool        // Whether the inputs for the job is still open or not
	Stats              JobStats    `json:"stats,omitempty"` // Job statistics
	TimeCreated        string      // Time the job was created at
	TimeDone           string      `json:"timeDone,omitempty"`           // Time the job was completed
	TimeArchiveStarted string      `json:"timeArchiveStarted,omitempty"` // Time the job archiving started
	TimeArchiveDone    string      `json:"timeArchiveDone,omitempty"`    // Time the job archiving completed
	Phases             []Phase     `json:"phases"`                       // Job tasks
	Options            interface{} // Job options
}

Job represents the status of a job.

type JobError

type JobError struct {
	Id      string // Job Id
	Phase   string // Phase number of the failure
	What    string // A human readable summary of what failed
	Code    string // Error code
	Message string // Human readable error message
	Stderr  string // A key that saved the stderr for the given command (optional)
	Key     string // The input key being processed when the task failed (optional)
}

JobError represents an error occurred during a job execution

type JobStats

type JobStats struct {
	Errors    int // Number or errors
	Outputs   int // Number of output produced
	Retries   int // Number of retries
	Tasks     int // Total number of task in the job
	TasksDone int // number of tasks done
}

JobStats represents statistics about a job

type ListDirectoryOpts

type ListDirectoryOpts struct {
	Limit  int    `json:"limit"`  // Limit to the number of records returned (default and max is 1000)
	Marker string `json:"marker"` // Key name at which to start the next listing
}

ListDirectoryOpts represent the option that can be specified when listing a directory.

type Phase

type Phase struct {
	Type   string   `json:"type,omitempty"`   // Task type, one of 'map' or 'reduce' (optional)
	Assets []string `json:"assets,omitempty"` // An array of objects to be placed in the compute zones (optional)
	Exec   string   `json:"exec"`             // The actual shell statement to execute
	Init   string   `json:"init"`             // Shell statement to execute in each compute zone before any tasks are executed
	Count  int      `json:"count,omitempty"`  // If type is 'reduce', an optional number of reducers for this phase (default is 1)
	Memory int      `json:"memory,omitempty"` // Amount of DRAM to give to your compute zone (in Mb, optional)
	Disk   int      `json:"disk,omitempty"`   // Amount of disk space to give to your compute zone (in Gb, optional)
}

Phase represents a task to be executed as part of a Job

Jump to

Keyboard shortcuts

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