Skip to content

Latest commit

 

History

History
284 lines (237 loc) · 9.74 KB

classifications.md

File metadata and controls

284 lines (237 loc) · 9.74 KB

Classifications

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.

Add initial classifications

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
	});

List all classifications

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
	});

Add another classification

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
	});

Update a classification

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
	});

Add classification to file

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
	});

Update classification on 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
	});

Get classification on 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
	});

Remove classification from file

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
	});;

Add classification to folder

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
	});

Update classification on 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
	});

Get classification on 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
	});

Remove classification from folder

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
	});;