files

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Overview

Package files provides API calls related to files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(fileUrl string, dest string) error

DownloadFile writes file response to destination file. If stopped with ^c (SIGINT), removes the invalid file.

func UpdateFileDetails

func UpdateFileDetails(fileId string, fdMap FileDetailsMap) (respBody []byte, err error)

UpdateFileDetails will update file details for that fileId. It will make two separate PATCH requests. One is for updating multiple metadata fields; the other is for basic fields like name and tags

Types

type File

type File struct {
	Href    string `json:"href"`
	Id      string `json:"id"`
	Name    string `json:"name"`
	Parent  string `json:"parent"`
	Project string `json:"project"`
	Type    string `json:"type"`
}

File contains all the JSON fields from one File.

func GetFiles

func GetFiles(project string) (files []File, err error)

GetFiles will get first 1-100 (limit) files for the given project. The totalOffset is obtained from X-Total-Matching-Query header. Based on that value we know how many times to make a new GET request. On each GET request we get []byte which we unmarshal to array of files. All file arrays gets merged into one which this function returns.

type FileDetails

type FileDetails struct {
	Href       string `json:"href"`
	Id         string `json:"id"`
	Name       string `json:"name"`
	Size       int    `json:"size"`
	Project    string `json:"project"`
	CreatedOn  string `json:"created_on"`
	ModifiedOn string `json:"modified_on"`
	Storage    struct {
		Type     string `json:"type"`
		Volume   string `json:"volume"`
		Location string `json:"location"`
	} `json:"storage"`
	Origin struct {
		Dataset string `json:"dataset"`
	} `json:"origin"`
	Tags     []string          `json:"tags"`
	Metadata map[string]string `json:"metadata"`
}

FileDetails contains all the JSON fields from details about a specific File.

func GetFileDetails

func GetFileDetails(fileId string) (fDetails *FileDetails, err error)

GetFileDetails will get all the details for that fileId.

type FileDetailsMap

type FileDetailsMap map[string]interface{}

FileDetailsMap is just an alias for map used for marshaling the FileDetails JSON.

type FileDetailsMetadataMap

type FileDetailsMetadataMap map[string]string

FileDetailsMetadataMap is just an alias for map used as FileDetailsMap metadata JSON field.

type FileUrl

type FileUrl struct {
	Url string `json:"url"`
}

FileUrl contains download link json field

func GetDownloadLink(fileId string) (fUrl FileUrl, err error)

GetDownloadLink gets download link for the given file id.

type JsonResponse

type JsonResponse struct {
	Href  string `json:"href"`
	Items []File `json:"items"`
}

JsonResponse contains self link and array of Files.

Jump to

Keyboard shortcuts

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