Metadata Categories

A MetadataCategory defines a reusable set of Custom Metadata rules that can be assigned to folders via a folder behavior. Each category specifies named metadata keys with optional allowed-value constraints, and a set of default columns to display in the UI.

If a key's allowed_values array is empty, it is treated as a free-form text field. If the array is non-empty, the key is constrained to those values in the Web UI.

List Metadata Categories

SDK Method

\Files\Model\MetadataCategory::list;

Return Object

MetadataCategory[]

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Additional Arguments

Example Request

try {
  $metadata_categories = \Files\Model\MetadataCategory::list();
  foreach ($metadata_categories as $metadata_category) {
    // Operate on $metadata_category
  }
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

Show Metadata Category

SDK Method

\Files\Model\MetadataCategory::find;

Return Object

MetadataCategory

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
id
int64
Required
Metadata Category ID.

Example Request

try {
  $metadata_category = \Files\Model\MetadataCategory::find($id);
  // Operate on $metadata_category
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

List Metadata Categories by Path

SDK Method

\Files\Model\MetadataCategory::listFor;

Return Object

MetadataCategory[]

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
path
string
Required
Path to operate on.

Additional Arguments

Example Request

try {
  $metadata_categories = \Files\Model\MetadataCategory::listFor($path);
  foreach ($metadata_categories as $metadata_category) {
    // Operate on $metadata_category
  }
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

Create Metadata Category

SDK Method

\Files\Model\MetadataCategory::create;

Return Object

MetadataCategory

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
name
string
Required
Name of the metadata category.
default_columns
array(string)
Metadata keys that should appear as columns in the UI by default.

Example Request

try {
  $metadata_category = \Files\Model\MetadataCategory::create([
    'name' => "Approval Workflow"
  ]);
  // Operate on $metadata_category
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

Update Metadata Category

SDK Method

$metadata_category->update;

Return Object

MetadataCategory

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
name
string
Name of the metadata category.
default_columns
array(string)
Metadata keys that should appear as columns in the UI by default.

Example Request

try {
  // Find the metadata_category object by its id.
  $metadata_category = \Files\Model\MetadataCategory::find(id);
  $metadata_category->update([
    'name' => "Approval Workflow"
  ]);
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

Delete Metadata Category

SDK Method

$metadata_category->delete;

Return Object

No return value.

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Example Request

try {
  // Find the metadata_category object by its id.
  $metadata_category = \Files\Model\MetadataCategory::find(id);
  $metadata_category->delete();
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
  echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
  echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}

The MetadataCategory Object

Some of the methods above return a MetadataCategory object. The attributes of this object are listed below.

AttributeDescription
id
int64
Metadata Category ID
name
string
Name of the metadata category.
definitions
hash(string,array(string))
Map of key names to arrays of allowed values. An empty array means free-form text.
default_columns
array(string)
Metadata keys that should appear as columns in the UI by default.