dm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package md contains the Go wrappers for calls to Data Management API https://developer.autodesk.com/en/docs/data/v2/overview/

The API offers the following features:

  • Access data from Autodesk SaaS applications;
  • Manage and store files from your app on the Forge platform, independent of any Autodesk SaaS application;

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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"
	"github.com/apprentice3d/forge-api-go-client/dm"
	"log"
	"os"
)

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 {
		log.Fatalf("Failed to create a bucket: %s\n", err.Error())
	}

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

}
Output:

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) (result []byte, err error)

DownloadObject downloads an on object, given the URL-encoded object name.

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, data []byte) (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  int64  `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 ErrorResult

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

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

type ListedBuckets

type ListedBuckets struct {
	Items []struct {
		BucketKey   string `json:"bucketKey"`
		CreatedDate int64  `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 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.

Jump to

Keyboard shortcuts

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