Modules@robinpath/box
box

@robinpath/box

0.1.2Node.jsPublic

Box module for RobinPath.

Box

Box module for RobinPath.

Package: @robinpath/box | Category: Cloud Storage | Type: Integration

Authentication

box.setCredentials "your-credentials"

Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.

Use Cases

Use the box module when you need to:

  • listFolderItems -- Use box.listFolderItems to perform this operation
  • getFolderInfo -- Use box.getFolderInfo to perform this operation
  • createFolder -- Use box.createFolder to perform this operation
  • deleteFolder -- Use box.deleteFolder to perform this operation
  • getFileInfo -- Use box.getFileInfo to perform this operation

Quick Reference

FunctionDescriptionReturns
setCredentialsConfigure box credentials.object
listFolderItemslistFolderItemsobject
getFolderInfogetFolderInfoobject
createFoldercreateFolderobject
deleteFolderdeleteFolderobject
getFileInfogetFileInfoobject
downloadFiledownloadFileobject
deleteFiledeleteFileobject
copyFilecopyFileobject
moveFilemoveFileobject
uploadFileuploadFileobject
searchContentsearchContentobject
createSharedLinkcreateSharedLinkobject
getSharedLinkgetSharedLinkobject
listCollaborationslistCollaborationsobject
addCollaborationaddCollaborationobject
getUsergetUserobject
updateFileInfoupdateFileInfoobject
lockFilelockFileobject

Functions

setCredentials

Configure box credentials.

Module: box | Returns: object -- API response.

box.setCredentials
ParameterTypeRequiredDescription
accessTokenstringYesaccessToken

listFolderItems

listFolderItems

Module: box | Returns: object -- API response.

box.listFolderItems
ParameterTypeRequiredDescription
inputstringNoInput parameter

getFolderInfo

getFolderInfo

Module: box | Returns: object -- API response.

box.getFolderInfo
ParameterTypeRequiredDescription
inputstringNoInput parameter

createFolder

createFolder

Module: box | Returns: object -- API response.

box.createFolder
ParameterTypeRequiredDescription
inputstringNoInput parameter

deleteFolder

deleteFolder

Module: box | Returns: object -- API response.

box.deleteFolder
ParameterTypeRequiredDescription
inputstringNoInput parameter

getFileInfo

getFileInfo

Module: box | Returns: object -- API response.

box.getFileInfo
ParameterTypeRequiredDescription
inputstringNoInput parameter

downloadFile

downloadFile

Module: box | Returns: object -- API response.

box.downloadFile
ParameterTypeRequiredDescription
inputstringNoInput parameter

deleteFile

deleteFile

Module: box | Returns: object -- API response.

box.deleteFile
ParameterTypeRequiredDescription
inputstringNoInput parameter

copyFile

copyFile

Module: box | Returns: object -- API response.

box.copyFile
ParameterTypeRequiredDescription
inputstringNoInput parameter

moveFile

moveFile

Module: box | Returns: object -- API response.

box.moveFile
ParameterTypeRequiredDescription
inputstringNoInput parameter

uploadFile

uploadFile

Module: box | Returns: object -- API response.

box.uploadFile
ParameterTypeRequiredDescription
inputstringNoInput parameter

searchContent

searchContent

Module: box | Returns: object -- API response.

box.searchContent
ParameterTypeRequiredDescription
inputstringNoInput parameter

createSharedLink

createSharedLink

Module: box | Returns: object -- API response.

box.createSharedLink
ParameterTypeRequiredDescription
inputstringNoInput parameter

getSharedLink

getSharedLink

Module: box | Returns: object -- API response.

box.getSharedLink
ParameterTypeRequiredDescription
inputstringNoInput parameter

listCollaborations

listCollaborations

Module: box | Returns: object -- API response.

box.listCollaborations
ParameterTypeRequiredDescription
inputstringNoInput parameter

addCollaboration

addCollaboration

Module: box | Returns: object -- API response.

box.addCollaboration
ParameterTypeRequiredDescription
inputstringNoInput parameter

getUser

getUser

Module: box | Returns: object -- API response.

box.getUser
ParameterTypeRequiredDescription
inputstringNoInput parameter

updateFileInfo

updateFileInfo

Module: box | Returns: object -- API response.

box.updateFileInfo
ParameterTypeRequiredDescription
inputstringNoInput parameter

lockFile

lockFile

Module: box | Returns: object -- API response.

box.lockFile
ParameterTypeRequiredDescription
inputstringNoInput parameter

Error Handling

All functions throw on failure. Common errors:

ErrorCause
Box API error (${res.status}): ${t}Check the error message for details
box.setCredentials requires accessToken.Check the error message for details
box.deleteFolder requires an ID.Check the error message for details
box.deleteFile requires an ID.Check the error message for details
box.copyFile requires an ID.Check the error message for details
box.moveFile requires an ID.Check the error message for details
box.updateFileInfo requires an ID.Check the error message for details
box.lockFile requires an ID.Check the error message for details
@desc "List folder items and validate result"
do
  set $result as box.listFolderItems
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. List and iterate FolderItems

Retrieve all items and loop through them.

@desc "Setup authentication"
do
  box.setCredentials $token
enddo

@desc "List folder items and iterate results"
do
  set $result as box.listFolderItems
  each $item in $result
    print $item
  end
enddo

2. Create a new item with createFolder

Create a new resource and capture the result.

@desc "Setup authentication"
do
  box.setCredentials $token
enddo

@desc "Create folder"
do
  set $result as box.createFolder
  print "Created: " + $result
enddo

3. Create and update workflow

Create an item and then update it.

@desc "Setup authentication"
do
  box.setCredentials $token
enddo

@desc "Create folder and update file info"
do
  set $created as box.createFolder
  # Update the created item
  box.updateFileInfo
enddo

4. Check before creating

List existing items and only create if needed.

@desc "Setup authentication"
do
  box.setCredentials $token
enddo

@desc "List folder items and create folder"
do
  set $existing as box.listFolderItems
  if $existing == null
    box.createFolder
    print "Item created"
  else
    print "Item already exists"
  end
enddo

5. Multi-step Box workflow

Chain multiple box operations together.

@desc "Setup authentication"
do
  box.setCredentials $token
enddo

@desc "List folder items, get folder info, and more"
do
  set $r_listFolderItems as box.listFolderItems
  set $r_getFolderInfo as box.getFolderInfo
  set $r_createFolder as box.createFolder
  print "All operations complete"
enddo

6. Safe listFolderItems with validation

Check results before proceeding.

@desc "Setup authentication"
do
  box.setCredentials $token
enddo

@desc "List folder items and validate result"
do
  set $result as box.listFolderItems
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • s3 -- Amazon S3 module for complementary functionality
  • dropbox -- Dropbox module for complementary functionality
  • onedrive -- OneDrive module for complementary functionality
  • google-drive -- Google Drive module for complementary functionality
  • json -- JSON module for complementary functionality

Versions (1)

VersionTagPublished
0.1.2latest1 months ago
Install
$ robinpath add @robinpath/box

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.2
LicenseMIT
Unpacked Size4.8 KB
Versions1
Weekly Downloads26
Total Downloads26
Stars0
Last Publish1 months ago
Created1 months ago

Category

devops