Options
All
  • Public
  • Public/Protected
  • All
Menu

Client providing access to Autodesk Forge data management APIs.

tutorial

data-management

Hierarchy

Index

Constructors

constructor

  • Initializes new client with specific authentication method.

    Parameters

    • auth: IAuthOptions

      Authentication object, containing either client_id and client_secret properties (for 2-legged authentication), or a single token property (for 2-legged or 3-legged authentication with pre-generated access token).

    • Optional host: string
    • Optional region: US | EMEA

    Returns DataManagementClient

Properties

Protected Optional auth

Protected axios

axios: AxiosInstance

Protected host

host: string

Protected region

region: Region

Protected root

root: string

Protected Optional token

token: string

Methods

Private _collect

  • _collect(endpoint: string): Promise<any>

Private _pager

  • _pager(endpoint: string, limit: number): AsyncGenerator<any, void, unknown>
  • Parameters

    • endpoint: string
    • limit: number

    Returns AsyncGenerator<any, void, unknown>

copyObject

  • copyObject(bucket: string, oldObjectKey: string, newObjectKey: string): Promise<IObject>
  • Makes a copy of object under another name within the same bucket (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • bucket: string

      Bucket key.

    • oldObjectKey: string

      Original object key.

    • newObjectKey: string

      New object key.

    Returns Promise<IObject>

    Details of the new object copy.

createBucket

  • Creates a new bucket (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, incorrect scopes, or when a bucket with this name already exists.

    Parameters

    • bucket: string

      Bucket key.

    • dataRetention: DataRetentionPolicy

      Data retention policy for objects uploaded to this bucket.

    Returns Promise<IBucketDetail>

    Bucket details, with properties "bucketKey", "bucketOwner", "createdDate", "permissions", and "policyKey".

createSignedUrl

  • createSignedUrl(bucketId: string, objectId: string, access?: string): Promise<ISignedUrl>
  • Creates signed URL for specific object (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights.

    Parameters

    • bucketId: string

      Bucket key.

    • objectId: string

      Object key.

    • access: string = 'readwrite'

    Returns Promise<ISignedUrl>

    Description of the new signed URL resource.

Protected delete

  • delete(endpoint: string, headers?: {}, scopes: string[]): Promise<any>
  • Parameters

    • endpoint: string
    • headers: {} = {}
      • [name: string]: string
    • scopes: string[]

    Returns Promise<any>

deleteBucket

  • deleteBucket(bucketKey: string): Promise<any>
  • Deletes bucket (this endpoint is not documented on the Forge portal).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • bucketKey: string

      Bucket key.

    Returns Promise<any>

deleteObject

  • deleteObject(bucketKey: string, objectName: string): Promise<any>
  • Deletes object (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • bucketKey: string

      Bucket key.

    • objectName: string

      Name of object to delete.

    Returns Promise<any>

downloadObject

  • downloadObject(bucket: string, object: string): Promise<ArrayBuffer>
  • Downloads content of a specific bucket object (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    example

    const buff = await dataManagementClient.downloadObject(bucketKey, objectKey); fs.writeFileSync(filepath, Buffer.from(buff), { encoding: 'binary' });

    Parameters

    • bucket: string

      Bucket key.

    • object: string

      Object name.

    Returns Promise<ArrayBuffer>

    Object content.

downloadObjectStream

  • downloadObjectStream(bucket: string, object: string): Promise<ReadableStream<any>>
  • Downloads content stream of a specific bucket object (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    example

    const stream = await dataManagementClient.downloadObjectStream(bucketKey, objectKey); stream.pipe(fs.createWriteStream(filepath));

    Parameters

    • bucket: string

      Bucket key.

    • object: string

      Object name.

    Returns Promise<ReadableStream<any>>

    Object content stream.

Protected fetch

  • fetch(config: AxiosRequestConfig): Promise<AxiosResponse<any>>

Protected get

  • get(endpoint: string, headers?: {}, scopes: string[], repeatOn202?: boolean): Promise<any>
  • Parameters

    • endpoint: string
    • headers: {} = {}
      • [name: string]: string
    • scopes: string[]
    • repeatOn202: boolean = false

    Returns Promise<any>

getBucketDetails

  • Gets details of a specific bucket (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or when a bucket with this name does not exist.

    Parameters

    • bucket: string

      Bucket key.

    Returns Promise<IBucketDetail>

    Bucket details, with properties "bucketKey", "bucketOwner", "createdDate", "permissions", and "policyKey".

Protected getBuffer

  • getBuffer(endpoint: string, headers?: {}, scopes: string[], repeatOn202?: boolean): Promise<any>
  • Parameters

    • endpoint: string
    • headers: {} = {}
      • [name: string]: string
    • scopes: string[]
    • repeatOn202: boolean = false

    Returns Promise<any>

getObjectDetails

  • getObjectDetails(bucket: string, object: string): Promise<IObject>
  • Gets details of a specific bucket object (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or when an object with this name does not exist.

    Parameters

    • bucket: string

      Bucket key.

    • object: string

      Object name.

    Returns Promise<IObject>

    Object description containing 'bucketKey', 'objectKey', 'objectId', 'sha1', 'size', 'location', and 'contentType'.

getResumableUploadStatus

  • getResumableUploadStatus(bucketKey: string, objectName: string, sessionId: string): Promise<IResumableUploadRange[]>
  • Gets status of a resumable upload session (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • bucketKey: string

      Bucket key.

    • objectName: string

      Name of uploaded object.

    • sessionId: string

      Resumable session ID.

    Returns Promise<IResumableUploadRange[]>

    List of range objects, with each object specifying 'start' and 'end' byte offsets of data that has already been uploaded.

Protected getStream

  • getStream(endpoint: string, headers?: {}, scopes: string[], repeatOn202?: boolean): Promise<any>
  • Parameters

    • endpoint: string
    • headers: {} = {}
      • [name: string]: string
    • scopes: string[]
    • repeatOn202: boolean = false

    Returns Promise<any>

iterateBuckets

  • iterateBuckets(limit?: number): AsyncIterable<IBucket[]>
  • Iterates over all buckets in pages of predefined size (docs).

    async
    generator
    yields

    {AsyncIterable<IBucket[]>} List of bucket object containing 'bucketKey', 'createdDate', and 'policyKey'.

    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • limit: number = 16

    Returns AsyncIterable<IBucket[]>

iterateObjects

  • iterateObjects(bucket: string, limit?: number, beginsWith?: string): AsyncIterable<IObject[]>
  • Iterates over all objects in a bucket in pages of predefined size (docs).

    async
    generator
    yields

    {AsyncIterable<IObject[]>} List of object containing 'bucketKey', 'objectKey', 'objectId', 'sha1', 'size', and 'location'.

    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • bucket: string

      Bucket key.

    • limit: number = 16
    • Optional beginsWith: string

    Returns AsyncIterable<IObject[]>

listBuckets

  • listBuckets(): Promise<IBucket[]>
  • Lists all buckets (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Returns Promise<IBucket[]>

    List of bucket objects.

listObjects

  • listObjects(bucket: string, beginsWith?: string): Promise<IObject[]>
  • Lists all objects in a bucket (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • bucket: string

      Bucket key.

    • Optional beginsWith: string

    Returns Promise<IObject[]>

    List of object containing 'bucketKey', 'objectKey', 'objectId', 'sha1', 'size', and 'location'.

Protected patch

  • patch(endpoint: string, data: any, headers?: {}, scopes: string[]): Promise<any>
  • Parameters

    • endpoint: string
    • data: any
    • headers: {} = {}
      • [name: string]: string
    • scopes: string[]

    Returns Promise<any>

Protected post

  • post(endpoint: string, data: any, headers?: {}, scopes: string[]): Promise<any>
  • Parameters

    • endpoint: string
    • data: any
    • headers: {} = {}
      • [name: string]: string
    • scopes: string[]

    Returns Promise<any>

Protected put

  • put(endpoint: string, data: any, headers?: {}, scopes: string[]): Promise<any>
  • Parameters

    • endpoint: string
    • data: any
    • headers: {} = {}
      • [name: string]: string
    • scopes: string[]

    Returns Promise<any>

reset

  • reset(auth?: { client_id: string; client_secret: string } | { token: string }, host?: string, region?: US | EMEA): void
  • Resets client to specific authentication method, Forge host, and availability region.

    Parameters

    • Optional auth: { client_id: string; client_secret: string } | { token: string }
    • Optional host: string
    • Optional region: US | EMEA

    Returns void

Protected setAuthorization

  • setAuthorization(options: any, scopes: string[]): Promise<void>

uploadObject

  • uploadObject(bucket: string, name: string, contentType: string, data: Buffer): Promise<IObject>
  • Uploads content to a specific bucket object (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • bucket: string

      Bucket key.

    • name: string

      Name of uploaded object.

    • contentType: string

      Type of content to be used in HTTP headers, for example, "application/json".

    • data: Buffer

      Object content.

    Returns Promise<IObject>

    Object description containing 'bucketKey', 'objectKey', 'objectId', 'sha1', 'size', 'location', and 'contentType'.

uploadObjectResumable

  • uploadObjectResumable(bucketKey: string, objectName: string, data: Buffer, byteOffset: number, totalBytes: number, sessionId: string, contentType?: string): Promise<any>
  • Uploads content to a specific bucket object using the resumable capabilities (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • bucketKey: string

      Bucket key.

    • objectName: string

      Name of uploaded object.

    • data: Buffer

      Object content.

    • byteOffset: number

      Byte offset of the uploaded blob in the target object.

    • totalBytes: number

      Total byte size of the target object.

    • sessionId: string

      Resumable session ID.

    • contentType: string = 'application/stream'

    Returns Promise<any>

uploadObjectStream

  • uploadObjectStream(bucket: string, name: string, contentType: string, stream: ReadableStream<any>): Promise<IObject>
  • Uploads content stream to a specific bucket object (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • bucket: string

      Bucket key.

    • name: string

      Name of uploaded object.

    • contentType: string

      Type of content to be used in HTTP headers, for example, "application/json".

    • stream: ReadableStream<any>

      Object content stream.

    Returns Promise<IObject>

    Object description containing 'bucketKey', 'objectKey', 'objectId', 'sha1', 'size', 'location', and 'contentType'.

uploadObjectStreamResumable

  • uploadObjectStreamResumable(bucketKey: string, objectName: string, stream: ReadableStream<any>, chunkBytes: number, byteOffset: number, totalBytes: number, sessionId: string, contentType?: string): Promise<any>
  • Uploads content stream to a specific bucket object using the resumable capabilities (docs).

    async
    throws

    Error when the request fails, for example, due to insufficient rights, or incorrect scopes.

    Parameters

    • bucketKey: string

      Bucket key.

    • objectName: string

      Name of uploaded object.

    • stream: ReadableStream<any>

      Object content stream.

    • chunkBytes: number

      Byte size of the stream to be uploaded.

    • byteOffset: number

      Byte offset of the uploaded blob in the target object.

    • totalBytes: number

      Total byte size of the target object.

    • sessionId: string

      Resumable session ID.

    • contentType: string = 'application/stream'

    Returns Promise<any>

Generated using TypeDoc