예제 #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)