Class: Metadata

Metadata(client) → {void}

Simple manager for interacting with all metadata endpoints and actions.

Constructor

new Metadata(client) → {void}

Parameters:
Name Type Description
client BoxClient The Box API Client that is responsible for making calls to the API
Source:
Returns:
Type
void

Members

(readonly) fieldTypes :MetadataFieldType

Valid metadata field types
Type:
Source:

Methods

createCascadePolicy(scope, templateKey, folderID, callbackopt) → {Promise.<Object>}

Add a new cascade policy to a folder/metadata template, causing the metadata template to be applied to all items and subfolders inside the folder. API Endpoint: '/metadata_cascade_policies' Method: POST
Parameters:
Name Type Attributes Description
scope string Metadata template scope for the template to cascade
templateKey string Metadata template key for the template to cascade
folderID string The ID of the folder to cascade over
callback function <optional>
Passed the cascade policy if successful
Source:
Returns:
Promise resolving to the cascade policy
Type
Promise.<Object>

createCascadePolicy(scope, templateKey, folderID, callbackopt) → {Promise.<Object>}

Add a new cascade policy to a folder/metadata template, causing the metadata template to be applied to all items and subfolders inside the folder. API Endpoint: '/metadata_cascade_policies' Method: POST
Parameters:
Name Type Attributes Description
scope string Metadata template scope for the template to cascade
templateKey string Metadata template key for the template to cascade
folderID string The ID of the folder to cascade over
callback function <optional>
Passed the cascade policy if successful
Source:
Returns:
Promise resolving to the cascade policy
Type
Promise.<Object>

createTemplate(templateName, fields, optionsopt, callbackopt) → {Promise.<Object>}

Create a new metadata template API Endpoint: '/metadata_templates/schema', Method: POST
Parameters:
Name Type Attributes Description
templateName string The name of the metadata template
fields Array.<MetadataTemplateField> A list of fields for the template
options Object <optional>
Optional parameters, can be left null in many cases
Properties
Name Type Attributes Default Description
templateKey string <optional>
The programmatic key for the template
hidden boolean <optional>
Whether the template should be hidden in the UI
scope string <optional>
enterprise The scope for the template, only 'enterprise' is supported for now
copyInstanceOnItemCopy boolean <optional>
Whether to include the metadata when a file or folder is copied
callback function <optional>
Passed the template if successful, error otherwise
Source:
Returns:
A promise resolving to the created template
Type
Promise.<Object>

createTemplate(templateName, fields, optionsopt, callbackopt) → {Promise.<Object>}

Create a new metadata template API Endpoint: '/metadata_templates/schema', Method: POST
Parameters:
Name Type Attributes Description
templateName string The name of the metadata template
fields Array.<MetadataTemplateField> A list of fields for the template
options Object <optional>
Optional parameters, can be left null in many cases
Properties
Name Type Attributes Default Description
templateKey string <optional>
The programmatic key for the template
hidden boolean <optional>
Whether the template should be hidden in the UI
scope string <optional>
enterprise The scope for the template, only 'enterprise' is supported for now
copyInstanceOnItemCopy boolean <optional>
Whether to include the metadata when a file or folder is copied
callback function <optional>
Passed the template if successful, error otherwise
Source:
Returns:
A promise resolving to the created template
Type
Promise.<Object>

deleteCascadePolicy(policyID, callbackopt) → {Promise.<void>}

Delete the metadata cascade policy with the given ID API Endpoint: '/metadata_cascade_policies/:policyID' Method: DELETE
Parameters:
Name Type Attributes Description
policyID string The ID of the policy to delete
callback function <optional>
Passed nothing if successful
Source:
Returns:
Promise resolving to nothing
Type
Promise.<void>

deleteCascadePolicy(policyID, callbackopt) → {Promise.<void>}

Delete the metadata cascade policy with the given ID API Endpoint: '/metadata_cascade_policies/:policyID' Method: DELETE
Parameters:
Name Type Attributes Description
policyID string The ID of the policy to delete
callback function <optional>
Passed nothing if successful
Source:
Returns:
Promise resolving to nothing
Type
Promise.<void>

deleteTemplate(scope, template, callbackopt) → {Promise.<void>}

Delete a metadata template from an enterprise. API Endpoint: '/metadata_templates/:scope/:template/schema' Method: DELETE
Parameters:
Name Type Attributes Description
scope string The scope of the template to delete
template string The template to delete
callback function <optional>
Passed empty response body if successful, err otherwise
Source:
See:
Returns:
A promise resolving to nothing
Type
Promise.<void>

deleteTemplate(scope, template, callbackopt) → {Promise.<void>}

Delete a metadata template from an enterprise. API Endpoint: '/metadata_templates/:scope/:template/schema' Method: DELETE
Parameters:
Name Type Attributes Description
scope string The scope of the template to delete
template string The template to delete
callback function <optional>
Passed empty response body if successful, err otherwise
Source:
See:
Returns:
A promise resolving to nothing
Type
Promise.<void>

forceApplyCascadePolicy(policyID, resolutionMethod, callbackopt) → {Promise.<void>}

If a policy already exists on a folder, this will apply that policy to all existing files and sub-folders within the target folder. API Endpoint: '/metadata_cascade_policies/:policyID/apply' Method: POST
Parameters:
Name Type Attributes Description
policyID string The ID of the policy to delete
resolutionMethod string How to resolve conflicts, either "none" or "overwrite"
callback function <optional>
Passed nothing if successful
Source:
Returns:
Promise resolving to nothing
Type
Promise.<void>

forceApplyCascadePolicy(policyID, resolutionMethod, callbackopt) → {Promise.<void>}

If a policy already exists on a folder, this will apply that policy to all existing files and sub-folders within the target folder. API Endpoint: '/metadata_cascade_policies/:policyID/apply' Method: POST
Parameters:
Name Type Attributes Description
policyID string The ID of the policy to delete
resolutionMethod string How to resolve conflicts, either "none" or "overwrite"
callback function <optional>
Passed nothing if successful
Source:
Returns:
Promise resolving to nothing
Type
Promise.<void>

getCascadePolicies(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Get the cascade policies associated with a given folder. API Endpoint: '/metadata_cascade_policies' Method: GET
Parameters:
Name Type Attributes Description
folderID string The ID of the folder to get cascade policies for
options Object <optional>
Optional parameters
Properties
Name Type Attributes Description
owner_enterprise_id string <optional>
ID of the enterprise to get policies for
callback function <optional>
Passed the collection of policies if successful
Source:
Returns:
Promise resolving to the collection of policies
Type
Promise.<Object>

getCascadePolicies(folderID, optionsopt, callbackopt) → {Promise.<Object>}

Get the cascade policies associated with a given folder. API Endpoint: '/metadata_cascade_policies' Method: GET
Parameters:
Name Type Attributes Description
folderID string The ID of the folder to get cascade policies for
options Object <optional>
Optional parameters
Properties
Name Type Attributes Description
owner_enterprise_id string <optional>
ID of the enterprise to get policies for
callback function <optional>
Passed the collection of policies if successful
Source:
Returns:
Promise resolving to the collection of policies
Type
Promise.<Object>

getCascadePolicy(policyID, callbackopt) → {Promise.<Object>}

Get a metadata cascade policy object by ID API Endpoint: '/metadata_cascade_policies/:policyID' Method: GET
Parameters:
Name Type Attributes Description
policyID string The ID of the policy to retrieve
callback function <optional>
Passed the cascade policy if successful
Source:
Returns:
Promise resolving to the cascade policy
Type
Promise.<Object>

getCascadePolicy(policyID, callbackopt) → {Promise.<Object>}

Get a metadata cascade policy object by ID API Endpoint: '/metadata_cascade_policies/:policyID' Method: GET
Parameters:
Name Type Attributes Description
policyID string The ID of the policy to retrieve
callback function <optional>
Passed the cascade policy if successful
Source:
Returns:
Promise resolving to the cascade policy
Type
Promise.<Object>

getTemplateByID(templateID, callbackopt) → {Promise.<Object>}

Retrieve the schema definition for a metadata template by ID API Endpoint: '/metadata_templates/:id' Method: GET
Parameters:
Name Type Attributes Description
templateID string The ID of the template to retrieve
callback function <optional>
Called with the template schema if successful
Source:
Returns:
A promise resolving to the template schema
Type
Promise.<Object>

getTemplateByID(templateID, callbackopt) → {Promise.<Object>}

Retrieve the schema definition for a metadata template by ID API Endpoint: '/metadata_templates/:id' Method: GET
Parameters:
Name Type Attributes Description
templateID string The ID of the template to retrieve
callback function <optional>
Called with the template schema if successful
Source:
Returns:
A promise resolving to the template schema
Type
Promise.<Object>

getTemplates(scope, callbackopt) → {Promise.<Object>}

Get all templates in a given scope API Endpoint: '/metadata_templates/:scope' Method: GET
Parameters:
Name Type Attributes Description
scope string The scope to retrieve templates for
callback function <optional>
Called with an array of templates when successful
Source:
Returns:
A promise resolving to the collection of templates
Type
Promise.<Object>

getTemplates(scope, callbackopt) → {Promise.<Object>}

Get all templates in a given scope API Endpoint: '/metadata_templates/:scope' Method: GET
Parameters:
Name Type Attributes Description
scope string The scope to retrieve templates for
callback function <optional>
Called with an array of templates when successful
Source:
Returns:
A promise resolving to the collection of templates
Type
Promise.<Object>

getTemplateSchema(scope, template, callbackopt) → {Promise.<Object>}

Retrieve the schema definition for a metadata template API Endpoint: '/metadata_templates/:scope/:template' Method: GET
Parameters:
Name Type Attributes Description
scope string The scope of the template, e.g. "enterprise"
template string The template to retrieve
callback function <optional>
Called with the template schema if successful
Source:
Returns:
A promise resolving to the template schema
Type
Promise.<Object>

getTemplateSchema(scope, template, callbackopt) → {Promise.<Object>}

Retrieve the schema definition for a metadata template API Endpoint: '/metadata_templates/:scope/:template' Method: GET
Parameters:
Name Type Attributes Description
scope string The scope of the template, e.g. "enterprise"
template string The template to retrieve
callback function <optional>
Called with the template schema if successful
Source:
Returns:
A promise resolving to the template schema
Type
Promise.<Object>

query(from, ancestorFolderId, optionsopt, callbackopt) → {Promise.<void>}

Query Box items by their metadata. API Endpoint: '/metadata_queries/execute_read' Method: POST
Parameters:
Name Type Attributes Description
from string The template used in the query. Must be in the form scope.templateKey
ancestorFolderId string The folder_id to which to restrain the query
options Object <optional>
Optional parameters
Properties
Name Type Attributes Default Description
query string <optional>
The logical expression of the query
query_params Object <optional>
Required if query present. The arguments for the query
order_by Object <optional>
The field_key(s) to order on and the corresponding direction(s)
fields Array <optional>
An array of fields to return
limit int <optional>
100 The number of results to return for a single request
marker string <optional>
Pagination marker
callback function <optional>
Passed a collection of items and their associated metadata
Source:
Returns:
Promise resolving to a collection of items and their associated metadata
Type
Promise.<void>

query(from, ancestorFolderId, optionsopt, callbackopt) → {Promise.<void>}

Query Box items by their metadata. API Endpoint: '/metadata_queries/execute_read' Method: POST
Parameters:
Name Type Attributes Description
from string The template used in the query. Must be in the form scope.templateKey
ancestorFolderId string The folder_id to which to restrain the query
options Object <optional>
Optional parameters
Properties
Name Type Attributes Default Description
query string <optional>
The logical expression of the query
query_params Object <optional>
Required if query present. The arguments for the query
order_by Object <optional>
The field_key(s) to order on and the corresponding direction(s)
fields Array <optional>
An array of fields to return
limit int <optional>
100 The number of results to return for a single request
marker string <optional>
Pagination marker
callback function <optional>
Passed a collection of items and their associated metadata
Source:
Returns:
Promise resolving to a collection of items and their associated metadata
Type
Promise.<void>

updateTemplate(scope, template, operations, callbackopt) → {Promise.<Object>}

Update a metadata template via one or more non-breaking operations. Each operation is a an object descrbing one change to the template or its fields. API Endpoint: '/metadata_templates/:scope/:template/schema' Method: PUT
Parameters:
Name Type Attributes Description
scope string The scope of the template to modify
template string The template to modify
operations Array.<Object> The operations to perform
callback function <optional>
Passed the updated template if successful, error otherwise
Source:
See:
Returns:
A promise resolving to the updated template
Type
Promise.<Object>

updateTemplate(scope, template, operations, callbackopt) → {Promise.<Object>}

Update a metadata template via one or more non-breaking operations. Each operation is a an object descrbing one change to the template or its fields. API Endpoint: '/metadata_templates/:scope/:template/schema' Method: PUT
Parameters:
Name Type Attributes Description
scope string The scope of the template to modify
template string The template to modify
operations Array.<Object> The operations to perform
callback function <optional>
Passed the updated template if successful, error otherwise
Source:
See:
Returns:
A promise resolving to the updated template
Type
Promise.<Object>