Tagging Archives

You can tag archives from within python or using the command line interface.

View the source for the code samples on this page in Python API: Tagging.

Tagging on archive creation

When creating archives, you can specify tags using the tags argument. Tags must be strings and will be coerced to lowercase as a standard. You can specify as many as you would like as elements in a list:

>>> archive1 = api.create(
...      'archive1',
...      tags=["foo", "Bar"],
...      metadata={'description': 'tag test 1 has bar'})
...
>>> archive1.get_tags()
[u'foo', u'bar']
>>>
>>> archive2 = api.create(
...      'archive2',
...      tags=["foo", "Baz"],
...      metadata={'description': 'tag test 1 has baz'})
...
>>> archive2.get_tags()
[u'foo', u'baz']
>>>
>>> archive2.add_tags(42)
>>> archive2.get_tags()
[u'foo', u'baz', u'42']

You can then search for archives that have these tags using the search() method:

>>> list(api.search('bar')) 
['archive1']

>>> list(api.search('baz')) 
['archive2']

>>> list(api.search('foo')) 
['archive1', 'archive2']

Searching for multiple tags yields the set of archives that match all of the criteria:

>>> archive3 = api.create(
...      'archive3',
...      tags=["foo", "bar", "baz"],
...      metadata={'description': 'tag test 3 has all the tags!'})
...

>>> list(api.search('bar', 'foo')) 
['archive1', 'archive3']

>>> list(api.search('bar', 'foo', 'baz')) 
['archive3']

Searches that include a set of tags not jointly found in any archives yield no results:

>>> list(api.search('qux')) 
[]
>>> list(api.search('foo', 'qux')) 
[]

Viewing and modifying tags on existing archives

Tags can be listed using the get_tags() method:

>>> archive1.get_tags() 
['foo', 'bar']

You can add tags to an archive using the add_tags() method:

>>> archive1.add_tags('qux')
>>>
>>> list(api.search('foo', 'qux')) 
['archive1']

Removing tags from an archive

Specific tags can be removed from an archive using the delete_tags() method:

>>> archive1.delete_tags('foo', 'bar')
>>>
>>> list(api.search('foo', 'bar')) 
['archive3']