- Find metadata template by instance ID
- Get metadata template by name
- Update metadata template
- Remove metadata template
- Get metadata template by ID
- List all global metadata templates
- List all metadata templates for enterprise
- Create metadata template
Finds a metadata template by searching for the ID of an instance of the template.
This operation is performed by calling function get_metadata_templates_by_instance_id
.
See the endpoint docs at API Reference.
client.metadata_templates.get_metadata_templates_by_instance_id(
created_metadata_instance.id
)
- metadata_instance_id
str
- The ID of an instance of the metadata template to find.
- marker
Optional[str]
- Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination. This requires
usemarker
to be set totrue
.
- Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination. This requires
- limit
Optional[int]
- The maximum number of items to return per page.
- extra_headers
Optional[Dict[str, Optional[str]]]
- Extra headers that will be included in the HTTP request.
This function returns a value of type MetadataTemplates
.
Returns a list containing the 1 metadata template that matches the instance ID.
Retrieves a metadata template by its scope
and templateKey
values.
To find the scope
and templateKey
for a template, list all templates for
an enterprise or globally, or list all templates applied to a file or folder.
This operation is performed by calling function get_metadata_template
.
See the endpoint docs at API Reference.
client.metadata_templates.get_metadata_template(
GetMetadataTemplateScope.ENTERPRISE, template.template_key
)
- scope
GetMetadataTemplateScope
- The scope of the metadata template Example: "global"
- template_key
str
- The name of the metadata template Example: "properties"
- extra_headers
Optional[Dict[str, Optional[str]]]
- Extra headers that will be included in the HTTP request.
This function returns a value of type MetadataTemplate
.
Returns the metadata template matching the scope
and template
name.
Updates a metadata template.
The metadata template can only be updated if the template already exists.
The update is applied atomically. If any errors occur during the application of the operations, the metadata template will not be changed.
This operation is performed by calling function update_metadata_template
.
See the endpoint docs at API Reference.
client.metadata_templates.update_metadata_template(
UpdateMetadataTemplateScope.ENTERPRISE,
template_key,
[
UpdateMetadataTemplateRequestBody(
op=UpdateMetadataTemplateRequestBodyOpField.ADDFIELD,
field_key="newfieldname",
data={"type": "string", "displayName": "newFieldName"},
)
],
)
- scope
UpdateMetadataTemplateScope
- The scope of the metadata template Example: "global"
- template_key
str
- The name of the metadata template Example: "properties"
- request_body
List[UpdateMetadataTemplateRequestBody]
- Request body of updateMetadataTemplate method
- extra_headers
Optional[Dict[str, Optional[str]]]
- Extra headers that will be included in the HTTP request.
This function returns a value of type MetadataTemplate
.
Returns the updated metadata template, with the custom template data included.
Delete a metadata template and its instances. This deletion is permanent and can not be reversed.
This operation is performed by calling function delete_metadata_template
.
See the endpoint docs at API Reference.
client.metadata_templates.delete_metadata_template(
DeleteMetadataTemplateScope.ENTERPRISE, template.template_key
)
- scope
DeleteMetadataTemplateScope
- The scope of the metadata template Example: "global"
- template_key
str
- The name of the metadata template Example: "properties"
- extra_headers
Optional[Dict[str, Optional[str]]]
- Extra headers that will be included in the HTTP request.
This function returns a value of type None
.
Returns an empty response when the metadata template is successfully deleted.
Retrieves a metadata template by its ID.
This operation is performed by calling function get_metadata_template_by_id
.
See the endpoint docs at API Reference.
client.metadata_templates.get_metadata_template_by_id(template.id)
- template_id
str
- The ID of the template Example: "f7a9891f"
- extra_headers
Optional[Dict[str, Optional[str]]]
- Extra headers that will be included in the HTTP request.
This function returns a value of type MetadataTemplate
.
Returns the metadata template that matches the ID.
Used to retrieve all generic, global metadata templates available to all enterprises using Box.
This operation is performed by calling function get_global_metadata_templates
.
See the endpoint docs at API Reference.
client.metadata_templates.get_global_metadata_templates()
- marker
Optional[str]
- Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination. This requires
usemarker
to be set totrue
.
- Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination. This requires
- limit
Optional[int]
- The maximum number of items to return per page.
- extra_headers
Optional[Dict[str, Optional[str]]]
- Extra headers that will be included in the HTTP request.
This function returns a value of type MetadataTemplates
.
Returns all of the metadata templates available to all enterprises and their corresponding schema.
Used to retrieve all metadata templates created to be used specifically within the user's enterprise
This operation is performed by calling function get_enterprise_metadata_templates
.
See the endpoint docs at API Reference.
client.metadata_templates.get_enterprise_metadata_templates()
- marker
Optional[str]
- Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination. This requires
usemarker
to be set totrue
.
- Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination. This requires
- limit
Optional[int]
- The maximum number of items to return per page.
- extra_headers
Optional[Dict[str, Optional[str]]]
- Extra headers that will be included in the HTTP request.
This function returns a value of type MetadataTemplates
.
Returns all of the metadata templates within an enterprise and their corresponding schema.
Creates a new metadata template that can be applied to files and folders.
This operation is performed by calling function create_metadata_template
.
See the endpoint docs at API Reference.
client.metadata_templates.create_metadata_template(
"enterprise",
template_key,
template_key=template_key,
fields=[
CreateMetadataTemplateFields(
type=CreateMetadataTemplateFieldsTypeField.STRING,
key="testName",
display_name="testName",
),
CreateMetadataTemplateFields(
type=CreateMetadataTemplateFieldsTypeField.FLOAT,
key="age",
display_name="age",
),
CreateMetadataTemplateFields(
type=CreateMetadataTemplateFieldsTypeField.DATE,
key="birthDate",
display_name="birthDate",
),
CreateMetadataTemplateFields(
type=CreateMetadataTemplateFieldsTypeField.ENUM,
key="countryCode",
display_name="countryCode",
options=[
CreateMetadataTemplateFieldsOptionsField(key="US"),
CreateMetadataTemplateFieldsOptionsField(key="CA"),
],
),
CreateMetadataTemplateFields(
type=CreateMetadataTemplateFieldsTypeField.MULTISELECT,
key="sports",
display_name="sports",
options=[
CreateMetadataTemplateFieldsOptionsField(key="basketball"),
CreateMetadataTemplateFieldsOptionsField(key="football"),
CreateMetadataTemplateFieldsOptionsField(key="tennis"),
],
),
],
)
- scope
str
- The scope of the metadata template to create. Applications can only create templates for use within the authenticated user's enterprise. This value needs to be set to
enterprise
, asglobal
scopes can not be created by applications.
- The scope of the metadata template to create. Applications can only create templates for use within the authenticated user's enterprise. This value needs to be set to
- template_key
Optional[str]
- A unique identifier for the template. This identifier needs to be unique across the enterprise for which the metadata template is being created. When not provided, the API will create a unique
templateKey
based on the value of thedisplayName
.
- A unique identifier for the template. This identifier needs to be unique across the enterprise for which the metadata template is being created. When not provided, the API will create a unique
- display_name
str
- The display name of the template.
- hidden
Optional[bool]
- Defines if this template is visible in the Box web app UI, or if it is purely intended for usage through the API.
- fields
Optional[List[CreateMetadataTemplateFields]]
- An ordered list of template fields which are part of the template. Each field can be a regular text field, date field, number field, as well as a single or multi-select list.
- copy_instance_on_item_copy
Optional[bool]
- Whether or not to copy any metadata attached to a file or folder when it is copied. By default, metadata is not copied along with a file or folder when it is copied.
- extra_headers
Optional[Dict[str, Optional[str]]]
- Extra headers that will be included in the HTTP request.
This function returns a value of type MetadataTemplate
.
The schema representing the metadata template created.