Skip to content

Commit 7549076

Browse files
Add support for copyInstanceOnItemCopy field for metadata templates (#546)
1 parent 30e4283 commit 7549076

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Next Release
77
++++++++
88
- Allow ints to be passed in as item IDs
99
- Fix bug with updating a collaboration role to owner
10+
- Add support for `copyInstanceOnItemCopy` field for metadata templates
1011

1112
2.9.0 (2020-06-23)
1213
++++++++

boxsdk/client/client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ def get_metadata_templates(self, scope='enterprise', limit=None, marker=None, fi
16231623
)
16241624

16251625
@api_call
1626-
def create_metadata_template(self, display_name, fields, template_key=None, hidden=False, scope='enterprise'):
1626+
def create_metadata_template(self, display_name, fields, template_key=None, hidden=False, scope='enterprise', copy_instance_on_item_copy=False):
16271627
"""
16281628
Create a new metadata template. By default, only the display name and fields are required; the template key
16291629
will be automatically generated based on the display name and the template will be created in the enterprise
@@ -1649,13 +1649,18 @@ def create_metadata_template(self, display_name, fields, template_key=None, hidd
16491649
The scope the template should be created in
16501650
:type scope:
16511651
`unicode`
1652+
:param copy_instance_on_item_copy:
1653+
Whether or not to include the metadata when a file or folder is copied.
1654+
:type copy_instance_on_item_copy:
1655+
`bool`
16521656
"""
16531657
url = self._session.get_url('metadata_templates', 'schema')
16541658
body = {
16551659
'scope': scope,
16561660
'displayName': display_name,
16571661
'hidden': hidden,
1658-
'fields': [field.json() for field in fields]
1662+
'fields': [field.json() for field in fields],
1663+
'copyInstanceOnItemCopy': copy_instance_on_item_copy
16591664
}
16601665

16611666
if template_key is not None:

docs/usage/metadata.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Create Metadata Template
3939
------------------------
4040

4141
To create a new metadata template, call
42-
[`client.create_metadata_template(display_name, fields, template_key=None, hidden=False, scope='enterprise')`][create_template]
42+
[`client.create_metadata_template(display_name, fields, template_key=None, hidden=False, scope='enterprise', copy_instance_on_item_copy=False)`][create_template]
4343
with the human-readable name of the template and the [`MetadataField`s][metadata_field_class] the template should have.
4444
You can optionally specify a key for the template, otherwise one will be derived from the display name. At the current
4545
time, only `enterprise` scope templates are supported. This method returns a
@@ -111,6 +111,7 @@ template = client.metadata_template('enterprise', 'employeeRecord')
111111
updates = template.start_update()
112112
updates.add_enum_option('state', 'WI')
113113
updates.edit_template({'hidden': False})
114+
updates.edit_template({'copyInstanceOnItemCopy': False})
114115
updated_template = template.update_info(updates)
115116
```
116117

test/unit/client/test_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,7 @@ def test_create_metadata_template(mock_client, mock_box_session):
12711271
],
12721272
},
12731273
],
1274+
'copyInstanceOnItemCopy': False,
12741275
'templateKey': 'vContract',
12751276
}
12761277

0 commit comments

Comments
 (0)