dm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes struct {
	Name                 string    `json:"name"`
	Extension            Extension `json:"extension"`
	Region               *string   `json:"region, omitempty"`
	Scopes               *[]string `json:"scopes, omitempty"`
	DisplayName          *string   `json:"displayName, omitempty"`
	ObjectCount          *int      `json:"objectCount, omitempty"`
	CreateTime           *string   `json:"createTime, omitempty"`
	CreateUserId         *string   `json:"createUserId, omitempty"`
	CreateUserName       *string   `json:"createUserName, omitempty"`
	LastModifiedTime     *string   `json:"lastModifiedTime, omitempty"`
	LastModifiedUserId   *string   `json:"lastModifiedUserId, omitempty"`
	LastModifiedUserName *string   `json:"lastModifiedUserName, omitempty"`
	Hidden               *bool     `json:"displayName, omitempty"`
	VersionNumber        *int      `json:"versionNumber, omitempty"`
	Mimetype             *string   `json:"mimeType, omitempty"`
	FileType             *string   `json:"fileType, omitempty"`
	StorageSize          *int      `json:"storageSize, omitempty"`
	Reserved             *bool     `json:"reserved, omitempty"`
	ReservedTime         *string   `json:"reservedTime, omitempty"`
	ReservedUserId       *string   `json:"reservedUserId, omitempty"`
	ReservedUserName     *string   `json:"reservedUserName, omitempty"`
	PathInProject        *string   `json:"pathInProject, omitempty"`
}

type BucketAPI

type BucketAPI struct {
	oauth.TwoLeggedAuth
	BucketAPIPath string
}

BucketAPI holds the necessary data for making Bucket related calls to Forge Data Management service

func NewBucketAPIWithCredentials

func NewBucketAPIWithCredentials(ClientID string, ClientSecret string) BucketAPI

NewBucketAPIWithCredentials returns a Bucket API client with default configurations

func (BucketAPI) CreateBucket

func (api BucketAPI) CreateBucket(bucketKey, policyKey string) (result BucketDetails, err error)

CreateBucket creates and returns details of created bucket, or an error on failure

Example
package main

import (
	"fmt"
	"os"

	"github.com/outer-labs/forge-api-go-client/dm"
)

func main() {

	// prepare the credentials
	clientID := os.Getenv("FORGE_CLIENT_ID")
	clientSecret := os.Getenv("FORGE_CLIENT_SECRET")

	bucketAPI := dm.NewBucketAPIWithCredentials(clientID, clientSecret)

	bucket, err := bucketAPI.CreateBucket("some_unique_name", "transient")

	if err != nil {
		// handle error
	}

	fmt.Printf("Bucket %s was created with policy %s\n",
		bucket.BucketKey,
		bucket.PolicyKey)

}

func (BucketAPI) DeleteBucket

func (api BucketAPI) DeleteBucket(bucketKey string) error

DeleteBucket deletes bucket given its key.

WARNING: The bucket delete call is undocumented.

func (BucketAPI) DownloadObject

func (api BucketAPI) DownloadObject(bucketKey string, objectName string) (reader io.ReadCloser, err error)

DownloadObject returns the reader stream of the response body Don't forget to close it!

func (BucketAPI) GetBucketDetails

func (api BucketAPI) GetBucketDetails(bucketKey string) (result BucketDetails, err error)

GetBucketDetails returns information associated to a bucket. See BucketDetails struct.

func (BucketAPI) ListBuckets

func (api BucketAPI) ListBuckets(region, limit, startAt string) (result ListedBuckets, err error)

ListBuckets returns a list of all buckets created or associated with Forge secrets used for token creation

func (BucketAPI) ListObjects

func (api BucketAPI) ListObjects(bucketKey, limit, beginsWith, startAt string) (result BucketContent, err error)

ListObjects returns the bucket contains along with details on each item.

func (BucketAPI) UploadObject

func (api BucketAPI) UploadObject(bucketKey string, objectName string, reader io.Reader) (result ObjectDetails, err error)

UploadObject adds to specified bucket the given data (can originate from a multipart-form or direct file read). Return details on uploaded object, including the object URN. Check ObjectDetails struct.

type BucketAPI3L

type BucketAPI3L struct {
	Auth           oauth.ThreeLeggedAuth
	Token          TokenRefresher
	BucketsAPIPath string
}

BucketAPI holds the necessary data for making Bucket related calls to Forge Data Management service

func NewBucketAPI3LWithCredentials

func NewBucketAPI3LWithCredentials(auth oauth.ThreeLeggedAuth, token TokenRefresher) *BucketAPI3L

NewBucketAPIWithCredentials returns a Bucket API client with default configurations

func (BucketAPI3L) CreateBucket3L

func (api BucketAPI3L) CreateBucket3L(bucketKey, policyKey string) (result BucketDetails, err error)

CreateBucket creates and returns details of created bucket, or an error on failure

func (BucketAPI3L) DeleteBucket3L

func (api BucketAPI3L) DeleteBucket3L(bucketKey string) error

DeleteBucket deletes bucket given its key.

WARNING: The bucket delete call is undocumented.

func (BucketAPI3L) DownloadObject3L

func (api BucketAPI3L) DownloadObject3L(bucketKey string, objectName string) (reader io.ReadCloser, err error)

DownloadObject returns the reader stream of the response body Don't forget to close it!

func (BucketAPI3L) GetBucketDetails3L

func (api BucketAPI3L) GetBucketDetails3L(bucketKey string) (result BucketDetails, err error)

GetBucketDetails returns information associated to a bucket. See BucketDetails struct.

func (BucketAPI3L) ListBuckets3L

func (api BucketAPI3L) ListBuckets3L(region, limit, startAt string) (result ListedBuckets, err error)

ListBuckets returns a list of all buckets created or associated with Forge secrets used for token creation

func (BucketAPI3L) ListObjects3L

func (api BucketAPI3L) ListObjects3L(bucketKey, limit, beginsWith, startAt string) (result BucketContent, err error)

ListObjects returns the bucket contains along with details on each item.

func (BucketAPI3L) UploadObject3L

func (api BucketAPI3L) UploadObject3L(bucketKey string, objectName string, reader io.Reader) (result ObjectDetails, err error)

UploadObject adds to specified bucket the given data (can originate from a multipart-form or direct file read). Return details on uploaded object, including the object URN. Check ObjectDetails struct.

type BucketContent

type BucketContent struct {
	Items []ObjectDetails `json:"items"`
	Next  string          `json:"next"`
}

BucketContent reflects the response when query Data Management API for bucket content.

type BucketDetails

type BucketDetails struct {
	BucketKey   string `json:"bucketKey"`
	BucketOwner string `json:"bucketOwner"`
	CreateDate  string `json:"createDate"`
	Permissions []struct {
		AuthID string `json:"authId"`
		Access string `json:"access"`
	} `json:"permissions"`
	PolicyKey string `json:"policyKey"`
}

BucketDetails reflects the body content received upon creation of a bucket

type CreateBucketRequest

type CreateBucketRequest struct {
	BucketKey string `json:"bucketKey"`
	PolicyKey string `json:"policyKey"`
}

CreateBucketRequest contains the data necessary to be passed upon bucket creation

type Data

type Data struct {
	Type          string         `json:"type"`
	Id            string         `json:"id"`
	Attributes    *Attributes    `json:"attributes, omitempty"`
	Relationships *Relationships `json:"relationships, omitempty"`
	Links         *Links         `json:"links, omitempty"`
}

type ErrorResult

type ErrorResult struct {
	Reason     string `json:"reason"`
	StatusCode int
}

ErrorResult reflects the body content when a request failed (g.e. Bad request or key conflict)

func (*ErrorResult) Error

func (e *ErrorResult) Error() string

type Extension

type Extension struct {
	Type    string   `json:"type"`
	Version string   `json:"version"`
	Schema  Href     `json:"schema"`
	Data    struct{} `json:"data"`
}

type FolderAPI

type FolderAPI struct {
	oauth.TwoLeggedAuth
	FolderAPIPath string
}

FolderAPI holds the necessary data for making calls to Forge Data Management service

func NewFolderAPIWithCredentials

func NewFolderAPIWithCredentials(ClientID string, ClientSecret string) FolderAPI

NewFolderAPIWithCredentials returns a Folder API client with default configurations

func (FolderAPI) GetFolderContents

func (api FolderAPI) GetFolderContents(projectKey, folderKey string) (result ForgeResponseArray, err error)

func (FolderAPI) GetFolderDetails

func (api FolderAPI) GetFolderDetails(projectKey, folderKey string) (result ForgeResponseObject, err error)

ListBuckets returns a list of all buckets created or associated with Forge secrets used for token creation

func (FolderAPI) GetItemDetails

func (api FolderAPI) GetItemDetails(projectKey, itemKey string) (result ForgeResponseObject, err error)

ListBuckets returns a list of all buckets created or associated with Forge secrets used for token creation

func (FolderAPI) GetItemTip

func (api FolderAPI) GetItemTip(projectKey, itemKey string) (result ForgeResponseObject, err error)

func (FolderAPI) GetItemVersions

func (api FolderAPI) GetItemVersions(projectKey, itemKey string) (result ForgeResponseArray, err error)

type FolderAPI3L

type FolderAPI3L struct {
	Auth          oauth.ThreeLeggedAuth
	Token         TokenRefresher
	FolderAPIPath string
}

func NewFolderAPI3LWithCredentials

func NewFolderAPI3LWithCredentials(
	auth oauth.ThreeLeggedAuth,
	token TokenRefresher,
) *FolderAPI3L

func (FolderAPI3L) GetFolderContentsThreeLegged

func (a FolderAPI3L) GetFolderContentsThreeLegged(projectKey, folderKey string) (result ForgeResponseArray, err error)

func (FolderAPI3L) GetFolderDetailsThreeLegged

func (a FolderAPI3L) GetFolderDetailsThreeLegged(projectKey, folderKey string) (result ForgeResponseObject, err error)

Three legged Folder api calls

func (FolderAPI3L) GetItemDetails3L

func (api FolderAPI3L) GetItemDetails3L(projectKey, itemKey string) (result ForgeResponseObject, err error)

ListBuckets returns a list of all buckets created or associated with Forge secrets used for token creation

func (FolderAPI3L) GetItemDetailsThreeLegged

func (a FolderAPI3L) GetItemDetailsThreeLegged(projectKey, itemKey string) (result ForgeResponseObject, err error)

type ForgeResponseArray

type ForgeResponseArray struct {
	JsonApi  JsonAPI `json:"jsonApi`
	Links    Links   `json:"links"`
	Data     []Data  `json:"data"`
	Included *[]Data `json:"included, omitempty"`
}

type ForgeResponseObject

type ForgeResponseObject struct {
	JsonApi  JsonAPI `json:"jsonApi`
	Links    Links   `json:"links"`
	Data     Data    `json:"data"`
	Included *[]Data `json:"included, omitempty"`
}

type Href

type Href struct {
	Href string `json:"href"`
}

type HubAPI

type HubAPI struct {
	oauth.TwoLeggedAuth
	HubAPIPath string
}

HubAPI holds the necessary data for making calls to Forge Data Management service

func NewHubAPIWithCredentials

func NewHubAPIWithCredentials(ClientID string, ClientSecret string) HubAPI

NewHubAPIWithCredentials returns a Hub API client with default configurations

func (HubAPI) GetHubDetails

func (api HubAPI) GetHubDetails(hubKey string) (result ForgeResponseObject, err error)

func (HubAPI) GetHubs

func (api HubAPI) GetHubs() (result ForgeResponseArray, err error)

func (HubAPI) GetProjectDetails

func (api HubAPI) GetProjectDetails(hubKey, projectKey string) (result ForgeResponseObject, err error)

func (HubAPI) GetTopFolders

func (api HubAPI) GetTopFolders(hubKey, projectKey string) (result ForgeResponseArray, err error)

func (HubAPI) ListProjects

func (api HubAPI) ListProjects(hubKey string) (result ForgeResponseArray, err error)

ListBuckets returns a list of all buckets created or associated with Forge secrets used for token creation

type HubAPI3L

type HubAPI3L struct {
	Auth       oauth.ThreeLeggedAuth
	Token      TokenRefresher
	HubAPIPath string
}

func NewHubAPI3LWithCredentials

func NewHubAPI3LWithCredentials(
	auth oauth.ThreeLeggedAuth,
	token TokenRefresher,
) *HubAPI3L

func (*HubAPI3L) GetHubDetailsThreeLegged

func (a *HubAPI3L) GetHubDetailsThreeLegged(hubKey string) (result ForgeResponseObject, err error)

func (*HubAPI3L) GetHubsThreeLegged

func (a *HubAPI3L) GetHubsThreeLegged() (result ForgeResponseArray, err error)

Hub functions for use with 3legged authentication

func (*HubAPI3L) GetProjectDetailsThreeLegged

func (a *HubAPI3L) GetProjectDetailsThreeLegged(hubKey, projectKey string) (result ForgeResponseObject, err error)

func (*HubAPI3L) GetTopFoldersThreeLegged

func (a *HubAPI3L) GetTopFoldersThreeLegged(hubKey, projectKey string) (result ForgeResponseArray, err error)

func (*HubAPI3L) ListProjectsThreeLegged

func (a *HubAPI3L) ListProjectsThreeLegged(hubKey string) (result ForgeResponseArray, err error)

type JsonAPI

type JsonAPI struct {
	Version string `json:"version"`
}
type Links struct {
	Self    *Href `json:"self, omitempty"`
	Related *Href `json:"related, omitempty"`
	First   *Href `json:"first, omitempty"`
	Prev    *Href `json:"prev, omitempty"`
	Next    *Href `json:"next, omitempty"`
}

type ListedBuckets

type ListedBuckets struct {
	Items []struct {
		BucketKey   string `json:"bucketKey"`
		CreatedDate uint64 `json:"createdDate"`
		PolicyKey   string `json:"policyKey"`
	} `json:"items"`
	Next string `json:"next"`
}

ListedBuckets reflects the response when query Data Management API for buckets associated with current Forge secrets.

type Meta

type Meta struct {
	Link Href `json:"href"`
}

type ObjectDetails

type ObjectDetails struct {
	BucketKey   string            `json:"bucketKey"`
	ObjectID    string            `json:"objectID"`
	ObjectKey   string            `json:"objectKey"`
	SHA1        string            `json:"sha1"`
	Size        uint64            `json:"size"`
	ContentType string            `json:"contentType, omitempty"`
	Location    string            `json:"location"`
	BlockSizes  []int64           `json:"blockSizes, omitempty"`
	Deltas      map[string]string `json:"deltas, omitempty"`
}

ObjectDetails reflects the data presented when uploading an object to a bucket or requesting details on object.

type RelatedLinks struct {
	Meta  *Meta  `json:"meta, omitempty"`
	Links *Links `json:"links, omitempty"`
	Data  *Data  `json:"data, omitempty"`
}

type Relationships

type Relationships struct {
	Hub             *RelatedLinks `json:"hub, omitempty"`
	Projects        *RelatedLinks `json:projects, omitempty"`
	RootFolder      *RelatedLinks `json:"rootFolder, omitempty"`
	TopFolders      *RelatedLinks `json:"topFolders, omitempty"`
	Parent          *RelatedLinks `json:"parent, omitempty"`
	Tip             *RelatedLinks `json:"tip, omitempty"`
	Versions        *RelatedLinks `json:"versions, omitempty"`
	Contents        *RelatedLinks `json:"contents, omitempty"`
	Refs            *RelatedLinks `json:"refs, omitempty"`
	Links           *RelatedLinks `json:"links, omitempty"`
	Item            *RelatedLinks `json:"item, omitempty"`
	Storage         *RelatedLinks `json:"storage, omitempty"`
	Derivatives     *RelatedLinks `json:"derivatives, omitempty"`
	Thumbnails      *RelatedLinks `json:"thumbnails, omitempty"`
	DownloadFormats *RelatedLinks `json:"downloadFormats, omitempty"`
}

type TokenRefresher

type TokenRefresher interface {
	Bearer() *oauth.Bearer
	RefreshTokenIfRequired(auth oauth.ThreeLeggedAuth) error
}

Jump to

Keyboard shortcuts

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