mcstoreapi

package
v0.0.0-...-2be0f72 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPStatusToError

func HTTPStatusToError(status int) error

HTTPStatusToError translates an http state to an application error.

func MCClient

func MCClient() *ezhttp.EzClient

MCClient creates a new EzClient.

func MCUrl

func MCUrl() string

MCUrl returns the current mcurl config entry.

func ToError

func ToError(resp *http.Response, errs []error) error

ToError tests the list of errors and the response to determine the type of error to return. It calls HTTPStatusToError to translate response status codes to an error.

func ToJSON

func ToJSON(from string, to interface{}) error

ToJSON unmarshalls a string that contains JSON.

func Url

func Url(path string) string

Url create the url for accessing a service. It adds the mcurl to the path, and also adds the apikey argument.

Types

type CreateProjectRequest

type CreateProjectRequest struct {
	Name         string `json:"name"`
	MustNotExist bool   `json:"must_not_exist"`
}

CreateProjectRequest requests that a project be created. If MustNotExist is true, then the given project must not already exist. Existence is determined by the project name for that user.

type CreateProjectResponse

type CreateProjectResponse struct {
	ProjectID string `json:"project_id"`
	Existing  bool   `json:"existing"`
}

CreateProjectResponse returns the created project. If the project was an existing project and no new project was created then the Existing flag will be set to false.

type CreateUploadRequest

type CreateUploadRequest struct {
	ProjectID   string `json:"project_id"`
	DirectoryID string `json:"directory_id"`
	FileName    string `json:"filename"`
	FileSize    int64  `json:"filesize"`
	ChunkSize   int32  `json:"chunk_size"`
	FileMTime   string `json:"filemtime"`
	Checksum    string `json:"checksum"`
}

CreateRequest describes the JSON request a client will send to create a new upload request.

type CreateUploadResponse

type CreateUploadResponse struct {
	RequestID     string `json:"request_id"`
	StartingBlock uint   `json:"starting_block"`
}

uploadCreateResponse is the format of JSON sent back containing the upload request ID.

type DirectoryRequest

type DirectoryRequest struct {
	ProjectName string
	ProjectID   string
	Path        string
}

type GetDirectoryRequest

type GetDirectoryRequest struct {
	Path      string
	ProjectID string
}

GetDirectoryRequest is a request to get a directory for a project. The directory lookup is by path within the context of the given project.

type GetDirectoryResponse

type GetDirectoryResponse struct {
	DirectoryID string `json:"directory_id"`
	Path        string `json:"path"`
}

GetDirectoryResponse returns the directory id for a directory path for a given project.

type ServerAPI

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

func NewServerAPI

func NewServerAPI() *ServerAPI

NewServerAPI creates a new ServerAPI

func (*ServerAPI) CreateProject

func (s *ServerAPI) CreateProject(req CreateProjectRequest) (*CreateProjectResponse, error)

func (*ServerAPI) CreateUpload

func (s *ServerAPI) CreateUpload(req CreateUploadRequest) (*CreateUploadResponse, error)

CreateUploadRequest will request an upload request from the server. If an existing upload matches the request then server will send the existing upload request.

func (*ServerAPI) DeleteUploadRequest

func (s *ServerAPI) DeleteUploadRequest(uploadID string) error

DeleteUploadRequest will delete a given upload request.

func (*ServerAPI) DownloadFile

func (s *ServerAPI) DownloadFile(projectID, fileID, fpath string) error

func (*ServerAPI) GetDirectory

func (s *ServerAPI) GetDirectory(req DirectoryRequest) (directoryID string, err error)

func (*ServerAPI) GetDirectoryList

func (s *ServerAPI) GetDirectoryList(projectID, directoryID string) (*ServerDir, error)

func (*ServerAPI) GetFileForPath

func (s *ServerAPI) GetFileForPath(projectID, fpath string) (*ServerFile, error)

func (*ServerAPI) GetUserAPIKey

func (s *ServerAPI) GetUserAPIKey(username, password string) (apikey string, err error)

GetUserAPIKey will return the users APIKey

func (*ServerAPI) ListUploadRequests

func (s *ServerAPI) ListUploadRequests(projectID string) ([]UploadEntry, error)

ListUploadRequests will return all the upload requests for a given project ID.

func (*ServerAPI) SendFlowData

func (s *ServerAPI) SendFlowData(req *flow.Request) (*UploadChunkResponse, error)

SendFlowData will send the data for a flow request.

type ServerDir

type ServerDir struct {
	ID       string      `json:"id"`
	Type     string      `json:"otype"`
	Size     int64       `json:"size"`
	Name     string      `json:"name"`
	Path     string      `json:"path"`
	Checksum string      `json:"checksum"`
	Children []ServerDir `json:"children"`
}

type ServerFile

type ServerFile struct {
	ID       string `json:"id"`
	Checksum string `json:"checksum"`
	Size     int64  `json:"size"`
}

type UploadChunkResponse

type UploadChunkResponse struct {
	FileID string `json:"file_id"`
	Done   bool   `json:"done"`
}

type UploadEntry

type UploadEntry struct {
	RequestID   string    `json:"request_id"`
	FileName    string    `json:"filename"`
	DirectoryID string    `json:"directory_id"`
	ProjectID   string    `json:"project_id"`
	Size        int64     `json:"size"`
	Host        string    `json:"host"`
	Checksum    string    `json:"checksum"`
	Birthtime   time.Time `json:"birthtime"`
}

UploadEntry is a client side representation of an upload.

Jump to

Keyboard shortcuts

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