Пример #1
0
def create_item(api_key,
                collection,
                name,
                url=None,
                custom=None,
                trackable=None,
                content=None):
    """Create a collection with a given @name, belonging to @collection.
    The fields @url, @custom, @trackable and @content are optional."""
    collection = "/api/%s/collection/%s/" % (settings.MANAGEMENT_API_VERSION,
                                             collection)
    data = {
        'collection': collection,
        'name': name,
    }
    if url is not None:
        data['url'] = url
    if custom is not None:
        data['custom'] = custom
    if trackable is not None:
        data['trackable'] = trackable
    if content is not None:
        data['content'] = content

    return _create_object(api_key, "item", data)
Пример #2
0
def create_item(api_key,
                collection,
                name,
                url=None,
                custom=None,
                trackable=None,
                content=None,
                tags=None):
    """Create a collection with a given @name, belonging to @collection.
    The fields @url, @custom, @trackable and @content are optional."""
    data = {
        'collection': _get_object_uri('collection', collection),
        'name': name,
    }
    if url is not None:
        data['url'] = url
    if custom is not None:
        data['custom'] = custom
    if trackable is not None:
        data['trackable'] = trackable
    if content is not None:
        data['content'] = content
    if tags is not None:
        data['tags'] = map(lambda uuid: _get_object_uri('tag', uuid), tags)

    return _create_object(api_key, "item", data)
Пример #3
0
def create_app(api_key, collection, name):
    """Create an application with a given @name, belonging to @collection."""
    data = {
        'collection': _get_object_uri('collection', collection),
        'name': name,
    }

    return _create_object(api_key, "app", data)
Пример #4
0
def create_token(api_key, collection, tags=None):
    "Create a token, belongs to @collection"
    data = {'collection': _get_object_uri('collection', collection)}

    if tags is not None:
        data['tags'] = map(lambda uuid: _get_object_uri('tag', uuid), tags)

    return _create_object(api_key, "token", data)
Пример #5
0
def create_token(api_key, collection, tags=None):
    "Create a token, belongs to @collection"
    data = {'collection': _get_object_uri('collection', collection)}

    if tags is not None:
        data['tags'] = map(lambda uuid: _get_object_uri('tag', uuid), tags)

    return _create_object(api_key, "token", data)
Пример #6
0
def create_app(api_key, collection, name):
    """Create an application with a given @name, belonging to @collection."""
    data = {
        'collection': _get_object_uri('collection', collection),
        'name': name,
    }

    return _create_object(api_key, "app", data)
Пример #7
0
def create_video_media(api_key, url, name=None):
    video_name = name or url.split("/")[-1]

    return _create_object(api_key, "media", {
        'mimetype': 'video',
        'name': video_name,
        'meta': json.dumps({'video-url': url})
    })
Пример #8
0
def create_video_media(api_key, url, name=None):
    video_name = name or url.split("/")[-1]

    return _create_object(
        api_key, "media", {
            'mimetype': 'video',
            'name': video_name,
            'meta': json.dumps({'video-url': url})
        })
Пример #9
0
def create_bundle(api_key, collection, app, version, tag=None):
    """Create a bundle with a given @name, belonging to @collection."""
    data = {
        "collection": collection,
        "version": version,
        "app": app,
    }
    if tag:
        data["tag"] = tag

    for object_type, uuid in data.items():
        data[object_type] = _get_object_uri(object_type, uuid)

    return _create_object(api_key, "collectionbundle", data)
Пример #10
0
def create_bundle(api_key, collection, app, version, tag=None):
    """Create a bundle with a given @name, belonging to @collection."""
    data = {
        "collection": collection,
        "version": version,
        "app": app,
    }
    if tag:
        data["tag"] = tag

    for object_type, uuid in data.items():
        data[object_type] = _get_object_uri(object_type, uuid)

    return _create_object(api_key, "collectionbundle", data)
Пример #11
0
def create_item(api_key, collection, name, url=None, custom=None, trackable=None, content=None):
    """Create a collection with a given @name, belonging to @collection.
    The fields @url, @custom, @trackable and @content are optional."""
    collection = "/api/%s/collection/%s/" % (settings.MANAGEMENT_API_VERSION, collection)
    data = {"collection": collection, "name": name}
    if url is not None:
        data["url"] = url
    if custom is not None:
        data["custom"] = custom
    if trackable is not None:
        data["trackable"] = trackable
    if content is not None:
        data["content"] = content

    return _create_object(api_key, "item", data)
Пример #12
0
def create_item(api_key, collection, name, url=None, custom=None,
                trackable=None, content=None, tags=None):
    """Create a collection with a given @name, belonging to @collection.
    The fields @url, @custom, @trackable and @content are optional."""
    data = {
        'collection': _get_object_uri('collection', collection),
        'name': name,
    }
    if url is not None:
        data['url'] = url
    if custom is not None:
        data['custom'] = custom
    if trackable is not None:
        data['trackable'] = trackable
    if content is not None:
        data['content'] = content
    if tags is not None:
        data['tags'] = map(lambda uuid: _get_object_uri('tag', uuid), tags)

    return _create_object(api_key, "item", data)
Пример #13
0
def create_token(api_key, collection):
    "Create a token, belongs to @collection"
    collection = "/api/%s/collection/%s/" % (settings.MANAGEMENT_API_VERSION,
                                             collection)
    data = {'collection': collection}
    return _create_object(api_key, "token", data)
Пример #14
0
def create_collection(api_key, name, offline=False):
    "Create a collection with a given @name (must be unique)"
    data = {'name': name, 'offline': offline}
    return _create_object(api_key, "collection", data)
Пример #15
0
def create_token(api_key, collection):
    "Create a token, belongs to @collection"
    data = {'collection': _get_object_uri('collection', collection)}

    return _create_object(api_key, "token", data)
Пример #16
0
def create_collection(api_key, name):
    "Create a collection with a given @name (must be unique)"
    data = {"name": name}
    return _create_object(api_key, "collection", data)
Пример #17
0
def create_token(api_key, collection):
    "Create a token, belongs to @collection"
    collection = "/api/%s/collection/%s/" % (settings.MANAGEMENT_API_VERSION, collection)
    data = {"collection": collection}
    return _create_object(api_key, "token", data)
Пример #18
0
def create_collection(api_key, name, offline=False):
    "Create a collection with a given @name (must be unique)"
    data = {'name': name, 'offline': offline}
    return _create_object(api_key, "collection", data)