commons

package
v0.1.3-beta Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2016 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package commons defines types and utility functions shared between all 3nigm4 packages, typically used to share REST APIs types to be used by server and clients.

Index

Constants

View Source
const (
	AckResponse = "ACK" // Acknowledge message;
	NakResponse = "NAK" // Not acknowledged message.
)

Response status messages

View Source
const (
	SecurityTokenKey = "3x4-Security-Token" // header key used to pass security token coded as hexadecimal.
)

Shared key values

Variables

This section is empty.

Functions

func RandomBytesForLen

func RandomBytesForLen(size int) ([]byte, error)

RandomBytesForLen creates a random secure data blob of length "size". If anything went wrong, or not enought entropy is available, the function returns an error.

Types

type CheckSum

type CheckSum struct {
	Hash []byte `bson:"hash" json:"hash"` // checksum of data struct;
	Type string `bson:"type" json:"type"` // used algorithm.
}

CheckSum of the uploaded file for later verify.

type CommandArguments

type CommandArguments struct {
	// used by all commands
	ResourceID string `json:"resourceid"` // id assigned to the chunk (required for all commands);
	// upload specifics
	Data         []byte        `json:"data,omitempty"`       // the data blob to be uploaded (required for upload);
	TimeToLive   time.Duration `json:"ttl,omitempty"`        // required time to live for the data chunk;
	Permission   Permission    `json:"permission,omitempty"` // the type of enforced permission (required for upload);
	SharingUsers []string      `json:"sharing,omitempty"`    // usernames of users enabled to access the file (only in case of Shared permission type).
}

CommandArguments argument for various commands the presence of some or all the properties depends on the invoked command.

type JobGetRequest

type JobGetRequest struct {
	Complete bool     `json:"complete"`           // the upload/download/delete tx has been completed;
	Error    string   `json:"error,omitempty"`    // error description, if any;
	Data     []byte   `json:"data,omitempty"`     // returned requested bytes;
	CheckSum CheckSum `json:"checksum,omitempty"` // data related checksum if any.
}

JobGetRequest verify API call struct returned to check is a required transaction (upload, download, delete) has been correctly performed.

type JobPostRequest

type JobPostRequest struct {
	Command   string            `json:"command"`   // the command type, available commands are: "UPLOAD", "DOWNLOAD", "DELETE";
	Arguments *CommandArguments `json:"arguments"` // command arguments.
}

JobPostRequest body for the POST job API that creates a new async job evaluating the value of the "Command" property.

type JobPostResponse

type JobPostResponse struct {
	JobID string `json:"jobid"` // id for the in processing upload.
}

JobPostResponse the returned message from the pre-flight call, the returned id should be used for the verify call.

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"` // the user name;
	Password string `json:"password"` // the password used by the user.
}

LoginRequest is used by the login API to recieve user's credentials, should always be used on an SSL/TLS protected session.

type LoginResponse

type LoginResponse struct {
	Token string `json:"token"` // the session token.
}

LoginResponse is used to respond with a session token to a login JSON request.

type LogoutResponse

type LogoutResponse struct {
	Invalidated string `json:"invalidated"` // the invalidated session token.
}

LogoutResponse returns the invalidated session token to REST API calls.

type OpResult

type OpResult struct {
	ID        string // file id string;
	RequestID string // request (tx) id string (not file id);
	Data      []byte // downloaded data, if any;
	Error     error  // setted if an error was produced fro the upload instruction.
}

OpResult this struct represent the status of an async operation, of any type (upload, download, delete, ...). Not all field will be present: Error and Data properties will be only present if an error occurred or a download transaction has been required. Notice that two id are managed: a file id (used to identify the target file on S3) and RequestID used to associate a request with the async result produced. This structure is intended for internal use and not to be exposed via APIs.

type Permission

type Permission int

Permission represent the read permission on files.

type StandardResponse

type StandardResponse struct {
	Status string `json:"status"` // status string;
	Error  string `json:"error"`  // error description.
}

StandardResponse is a generic response message used to pass non specific messages like everything is OK or an error occurred.

Jump to

Keyboard shortcuts

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