Classfications are a type of metadata that allows users and applications to define and assign a content classification to files and folders.
Classifications use the metadata APIs to add and remove classifications, and assign them to files. For more details on metadata templates please see the metadata documentation.
- Classifications
- Add initial classifications
- List all classifications
- Add another classification
- Update a classification
- Delete a classification
- Delete all classifications
- Add classification to file
- Update classification on file
- Get classification on file
- Remove classification from file
- Add classification to folder
- Update classification on folder
- Get classification on folder
- Remove classification from folder
If an enterprise does not already have a classification defined, the first classification(s)
can be added with the
metadata.createTemplate(templateName, fields, options, callback)
method.
client.metadata.createTemplate(
'Classification',
[
{
type: "enum",
key: "Box__Security__Classification__Key",
displayName: "Classification",
hidden: false,
options: [
{
key: "Classified",
staticConfig: {
classification: {
colorID: 7,
classificationDefinition: "Top Seret"
}
}
}
]
}
],
{
hidden: false,
templateKey: 'securityClassification-6VMVochwUWo'
}
)
.then(template => {
// the new classification template
});
To retrieve a list of all the classifications in an enterprise call the
metadata.getTemplateSchema(scope, template, callback)
method to get the classifciations template, which will contain a list of all the
classifications
client.metadata.getTemplateSchema('enterprise', 'securityClassification-6VMVochwUWo')
.then(template => {
// the classification template
});
To add another classification, call the
metadata.updateTemplate(scope, template, operations, callback)
method with the an operation to add a new classification to the template.
var operations = [{
op: "addEnumOption",
fieldKey: "Box__Security__Classification__Key",
data: {
key: "Sensitive",
classification: {
classificationDefinition: "Sensitive information that must not be shared.",
colorID: 4
}
}
}];
client.metadata.updateTemplate('enterprise', 'securityClassification-6VMVochwUWo', operations)
.then(template => {
// the updated classification template
});
To update an existing classification, call the
metadata.updateTemplate(scope, template, operations, callback)
method with the an operation to update the existing classification already present on the template.
var operations = [{
op: "editEnumOption",
fieldKey: "Box__Security__Classification__Key",
enumOptionKey: "Sensitive",
data: {
key: "Very Sensitive",
classification: {
classificationDefinition: "Sensitive information that must not be shared.",
colorID: 4
}
}
}];
client.metadata.updateTemplate('enterprise', 'securityClassification-6VMVochwUWo', operations)
.then(template => {
// the updated classification template
});
To add a classification to a file, call
files.setMetadata(fileID, scope, template, classification, callback)
with the name of the classification template, as well as the details of the classification
to add to the file.
var classification = {
Box__Security__Classification__Key: "Sensitive"
};
client.files.addMetadata('11111', 'enterprise', 'securityClassification-6VMVochwUWo', classification)
.then(metadata => {
// the classification applied to the file
});
To update a classification on a file, call
files.setMetadata(fileID, scope, template, classification, callback)
with the name of the classification template, as well as the details of the classification
to add to the file.
var classification = {
Box__Security__Classification__Key: "Sensitive"
};
client.files.addMetadata('11111', 'enterprise', 'securityClassification-6VMVochwUWo', classification)
.then(metadata => {
// the updated classification applied to the file
});
Retrieve the classification on a file by calling
files.getMetadata(fileID, scope, template, callback)
with the ID of the file.
client.files.getMetadata('11111', 'enterprise', 'securityClassification-6VMVochwUWo')
.then(metadata => {
// the metadata instance, which includes the applied metadata
});
A classification can be removed from a file by calling
files.deleteMetadata(fileID, scope, template, callback)
.
client.files.deleteMetadata('11111', 'enterprise', 'securityClassification-6VMVochwUWo')
.then(() => {
// removal succeeded — no value returned
});;
To add a classification to a folder, call
folders.setMetadata(folderID, scope, template, classification, callback)
with the name of the classification template, as well as the details of the classification
to add to the folder.
var classification = {
Box__Security__Classification__Key: "Sensitive"
};
client.folders.addMetadata('11111', 'enterprise', 'securityClassification-6VMVochwUWo', classification)
.then(metadata => {
// the classification applied to the folder
});
To update a classification on a folder, call
folders.setMetadata(folderID, scope, template, classification, callback)
with the name of the classification template, as well as the details of the classification
to add to the folder.
var classification = {
Box__Security__Classification__Key: "Sensitive"
};
client.folders.addMetadata('11111', 'enterprise', 'securityClassification-6VMVochwUWo', classification)
.then(metadata => {
// the updated classification applied to the folder
});
Retrieve the classification on a folder by calling
folders.getMetadata(folderID, scope, template, callback)
with the ID of the folder.
client.folders.getMetadata('11111', 'enterprise', 'securityClassification-6VMVochwUWo')
.then(metadata => {
// the metadata instance, which includes the applied metadata
});
A classification can be removed from a folder by calling
folders.deleteMetadata(folderID, scope, template, callback)
.
client.folders.deleteMetadata('11111', 'enterprise', 'securityClassification-6VMVochwUWo')
.then(() => {
// removal succeeded — no value returned
});;