示例#1
0
def _upsert_property(entity_type, entity_id, key, values, api_key=None,
                     request_kwargs=None):
    """A helper to wrap common property update functionality."""
    assertions.datatype_str('key', key)
    url = '/{}/{}/properties/{}'.format(entity_type, entity_id, key)
    return utils.request('PUT', url, data=values, api_key=api_key,
                         **(request_kwargs or {}))
def create_collection_action(type_,
                             collection,
                             timestamp=None,
                             identifiers=None,
                             location=None,
                             locationSource=None,
                             context=None,
                             customFields=None,
                             api_key=None,
                             request_kwargs=None):
    """Create an Action for a Collection."""
    kwargs = locals()
    del kwargs['request_kwargs']
    kwargs['type'] = kwargs['type_']
    del kwargs['type_']
    api_key = kwargs.pop('api_key', None)
    assertions.validate_field_specs(kwargs, action_field_specs)

    url = '/collections/{}/actions/{}'.format(collection, type_)

    return utils.request('POST',
                         url,
                         data=kwargs,
                         api_key=api_key,
                         **(request_kwargs or {}))
示例#3
0
def delete_product(product, api_key=None, request_kwargs=None):
    assertions.datatype_str('product', product)
    url = '/products/{}'.format(product)
    return utils.request('DELETE',
                         url,
                         api_key=api_key,
                         **(request_kwargs or {}))
示例#4
0
def create_collection(name,
                      description=None,
                      customFields=None,
                      collections=None,
                      tags=None,
                      api_key=None):
    """
    Create a new Collection.

    :param name:
    :type description: str
    :param description:
    :type description: str
    :param customFields:
    :type customFields: list of str
    :param collections:
    :type collections: list of str
    :param tags:
    :type tags: list of str
    :param api_key:
    :type api_key: str
    :return
    :rtype
    """
    kwargs = locals()
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    return utils.request('POST', '/collections', data=kwargs, api_key=api_key)
def activate_user(user_id, activationCode, api_key=None):
    """Activate an Application User."""
    assertions.datatype_str('user_id', user_id)
    assertions.datatype_str('activationCode', activationCode)
    url = '/auth/evrythng/users/{}/validate'.format(user_id)
    data = {'activationCode': activationCode}
    return utils.request('POST', url, data=data, api_key=api_key)
示例#6
0
def delete_device_thng(thng, api_key=None, request_kwargs=None):
    assertions.datatype_str('thng', thng)
    url = '/auth/evrythng/thngs/{}'.format(thng)
    return utils.request('DELETE',
                         url,
                         api_key=api_key,
                         **(request_kwargs or {}))
示例#7
0
def create_action_type(name, customFields=None, tags=None, scopes=None,
                       api_key=None):
    """Create an Action Type"""
    kwargs = locals()
    api_key = kwargs.pop('api_key', None)
    assertions.validate_field_specs(kwargs, field_specs)
    return utils.request('POST', '/actions', data=kwargs, api_key=api_key)
示例#8
0
def update_collection(collection, name=None, description=None,
                      customFields=None, collections=None, tags=None,
                      api_key=None, request_kwargs=None):
    """
    Update an existing Collection.

    :param collection: The Collection to update.
    :type collection: str
    :param name: The Name of the Collection.
    :type description: str
    :param description: The Description of the Collection.
    :type description: str
    :param customFields: The Custom Fields of Collection.
    :type customFields: dict
    :param collections: The Collections of the Collection.
    :type collections: list of str
    :param tags: The Tags of the Collection.
    :type tags: list of str
    :param api_key: The API key to authorize request against.
    :type api_key: str
    :return
    :rtype
    """
    kwargs = locals()
    del kwargs['request_kwargs']
    collection = kwargs.pop('collection')
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/collections/{}'.format(collection)
    return utils.request(
        'PUT', url, data=kwargs, api_key=api_key, **(request_kwargs or {}))
示例#9
0
def create_application(project, name, description=None, defaultUrl=None,
                       socialNetworks=None, tags=None, customFields=None,
                       api_key=None, request_kwargs=None):
    """
    Create an Application.

    :param project: The Project of the Application.
    :type project: str
    :param name: The Name of the Application.
    :type name: str
    :param description: The Description of the Application.
    :type description: str
    :param defaultUrl: The Default URL of the Application.
    :type defaultUrl: str
    :param socialNetworks: Social Networks that the Application supports.
    :type socialNetworks: dict of dicts
    :param tags: The Tags of the Application
    :type tags: list of str
    :param customFields: The Custom Fields of Application.
    :type customFields: dict
    :param api_key: The API key to authorize request against.
    :type api_key: str
    :return:
    """
    if socialNetworks is None:
        socialNetworks = {}
    kwargs = locals()
    del kwargs['request_kwargs']
    api_key = kwargs.pop('api_key', None)
    project = kwargs.pop('project')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/projects/{}/applications'.format(project)
    return utils.request('POST', url, data=kwargs, api_key=api_key,
                         **(request_kwargs or {}))
示例#10
0
def update_project(project_id, name=None, description=None, startsAt=None,
                   endsAt=None, tags=None, shortDomains=None,
                   customFields=None, api_key=None):
    """
    Update an existing Project.

    :param name:
    :type name: str
    :param description:
    :type description: str
    :param startsAt:
    :type startsAt: int
    :param endsAt:
    :type endsAt: int
    :param tags:
    :type tags: list of str
    :param shortDomains:
    :type shortDomains: list of str
    :param api_key:
    :type api_key: str
    :return A Project document.
    :rtype Response
    """
    kwargs = locals()
    api_key = kwargs.pop('api_key')
    project_id = kwargs.pop('project_id')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/projects/{}'.format(project_id)
    logger.debug('Updating Project {}...'.format(project_id))
    return utils.request('PUT', url, data=kwargs, api_key=api_key, accept=True)
示例#11
0
def update_reactor_bundle(project_id, application_id, bundle_bytes,
                          api_key=None, request_kwargs=None):
    """
    Update a Reactor via a bundle of files; A zip file containing main.js,
    package.json, etc.

    :param project_id: The ID of the Project.
    :type project_id: str
    :param application_id: The ID for the Application that is a child of the
                           Project for which the reactor script will be scoped
                           to.
    :type application_id: str
    :param bundle_bytes: The bytes that make up the Zip file containing the
                         bundle of files.
    :type bundle_bytes: bytes
    :param api_key: The API key to authorize request against.
    :type api_key: str
    :return:
    """
    kwargs = locals()
    del kwargs['request_kwargs']
    api_key = kwargs.pop('api_key', None)
    project_id = kwargs.pop('project_id')
    assertions.datatype_str('project_id', project_id)
    application_id = kwargs.pop('application_id')
    assertions.datatype_str('application_id', application_id)
    assertions.validate_field_specs(kwargs, reactor_bundle_field_specs)
    url = '/projects/{}/applications/{}/reactorScript'.format(
        project_id, application_id)
    files = {'file': bundle_bytes}
    return utils.request('PUT', url, files=files, api_key=api_key,
                         **(request_kwargs or {}))
示例#12
0
def create_collection(name,
                      description=None,
                      customFields=None,
                      collections=None,
                      tags=None,
                      api_key=None):
    """
    Create a new Collection.

    :param name: The Name of the Collection.
    :type description: str
    :param description: The Description of the Collection.
    :type description: str
    :param customFields: The Custom Fields of Collection.
    :type customFields: dict
    :param collections: The Collections of the Collection.
    :type collections: list of str
    :param tags: The Tags of the Collection.
    :type tags: list of str
    :param api_key: The API key to authorize request against.
    :type api_key: str
    :return
    :rtype
    """
    kwargs = locals()
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    return utils.request('POST', '/collections', data=kwargs, api_key=api_key)
示例#13
0
def create_property_on_product(product_id, key, value, timestamp=None,
                               api_key=None):
    kwargs = locals()
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/products/{}/properties'.format(product_id)
    return utils.request('POST', url, data=kwargs, api_key=api_key)
示例#14
0
def list_users(project_id, api_key=None, request_kwargs=None):
    """List Application Users."""
    assertions.datatype_str('project_id', project_id)
    return utils.request('GET',
                         '/users',
                         api_key=api_key,
                         **(request_kwargs or {}))
示例#15
0
def update_collection(collection,
                      name=None,
                      description=None,
                      customFields=None,
                      collections=None,
                      tags=None,
                      api_key=None):
    """
    Update an existing Collection.

    :param collection: The Collection to update.
    :type collection: str
    :param name: The Name of the Collection.
    :type description: str
    :param description: The Description of the Collection.
    :type description: str
    :param customFields: The Custom Fields of Collection.
    :type customFields: dict
    :param collections: The Collections of the Collection.
    :type collections: list of str
    :param tags: The Tags of the Collection.
    :type tags: list of str
    :param api_key: The API key to authorize request against.
    :type api_key: str
    :return
    :rtype
    """
    kwargs = locals()
    collection = kwargs.pop('collection')
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/collections/{}'.format(collection)
    return utils.request('PUT', url, data=kwargs, api_key=api_key)
示例#16
0
def update_property_on_thng(thngId, key, value, timestamp=None, api_key=None):
    kwargs = locals()
    thngId = kwargs.pop('thngId')
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/thngs/{}/properties'.format(thngId)
    return utils.request('PUT', url, data=kwargs, api_key=api_key)
示例#17
0
def activate_user(user, activationCode, api_key=None):
    """Activate an Application User."""
    assertions.datatype_str('user', user)
    assertions.datatype_str('activationCode', activationCode)
    url = '/auth/evrythng/users/{}/validate'.format(user)
    data = {'activationCode': activationCode}
    return utils.request('POST', url, data=data, api_key=api_key)
示例#18
0
def update_application(project_id, application_id, name=None, description=None,
                       defaultUrl=None, socialNetworks=None, tags=None,
                       customFields=None, api_key=None):
    """
    Update an Application.

    :param project_id: The Project of the Application.
    :type project_id: str
    :param application_id: The Application to update the details for.
    :type application_id: str
    :param name: The Name of the Application.
    :type name: str
    :param description: The Description of the Application.
    :type description: str
    :param defaultUrl: The Default URL of the Application.
    :type defaultUrl: str
    :param socialNetworks: Social Networks that the Application supports.
    :type socialNetworks: dict of dicts
    :param tags: The Tags of the Application.
    :type tags: list of str
    :param customFields: The Custom Fields of Application.
    :type customFields: dict
    :param api_key: The API key to authorize request against.
    :type api_key: str
    :return:
    """
    kwargs = locals()
    api_key = kwargs.pop('api_key', None)
    project_id = kwargs.pop('project_id')
    application_id = kwargs.pop('application_id')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/projects/{}/applications/{}'.format(project_id, application_id)
    return utils.request('PUT', url, data=kwargs, api_key=api_key, accept=True)
示例#19
0
def update_collection(collection_id, name=None, description=None,
                      customFields=None, collections=None, tags=None,
                      api_key=None):
    """
    Update an existing Collection.

    :param collection_id: The Collection to update.
    :type collection_id: str
    :param name:
    :type description: str
    :param description:
    :type description: str
    :param customFields:
    :type customFields: list of str
    :param collections:
    :type collections: list of str
    :param tags:
    :type tags: list of str
    :param api_key:
    :type api_key: str
    :return
    :rtype
    """
    kwargs = locals()
    collection_id = kwargs.pop('collection_id')
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/collections/{}'.format(collection_id)
    return utils.request(
        'PUT', url, data=kwargs, api_key=api_key)
示例#20
0
def create_product(name, description=None, brand=None, categories=None,
                   photos=None, url=None, identifiers=None, properties=None,
                   tags=None, customFields=None, api_key=None):
    kwargs = locals()
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    return utils.request('POST', '/products', data=kwargs, api_key=api_key)
示例#21
0
def read_collection_actions(collection, type_, api_key=None,
                            request_kwargs=None):
    """Read Actions for a Collection."""
    assertions.datatype_str('collection', collection)
    assertions.datatype_str('type_', type_)
    url = '/collections/{}/actions/{}'.format(collection, type_)
    return utils.request('GET', url, api_key=api_key, **(request_kwargs or {}))
示例#22
0
def update_reactor_bundle(project_id, application_id, bundle_bytes,
                          api_key=None):
    """
    Update a Reactor via a bundle of files; A zip file containing main.js,
    package.json, etc.

    :param project_id: The ID of the Project.
    :type project_id: str
    :param application_id: The ID for the Application that is a child of the
                           Project for which the reactor script will be scoped
                           to.
    :type application_id: str
    :param bundle_bytes: The bytes that make up the Zip file containing the
                         bundle of files.
    :type bundle_bytes: bytes
    :param api_key: The API key to authorize request against.
    :type api_key: str
    :return:
    """
    kwargs = locals()
    api_key = kwargs.pop('api_key', None)
    project_id = kwargs.pop('project_id')
    assertions.datatype_str('project_id', project_id)
    application_id = kwargs.pop('application_id')
    assertions.datatype_str('application_id', application_id)
    assertions.validate_field_specs(kwargs, reactor_bundle_field_specs)
    url = '/projects/{}/applications/{}/reactorScript'.format(
        project_id, application_id)
    files = {'file': bundle_bytes}
    return utils.request('PUT', url, files=files, api_key=api_key)
示例#23
0
def update_reactor_script(project_id, application_id, script, manifest='',
                          type_='simple', api_key=None):
    """
    Update the Reactor with a single script text file and an optional manifest.

    :param project_id: The ID of the Project.
    :type project_id: str
    :param application_id: The ID for the Application that is a child of the
                           Project for which the reactor script will be scoped
                           to.
    :type application_id: str
    :param script: The reactor script body.
    :type script: str
    :param manifest: The manifest file for running the script. A packages.json
                     file, basically.
    :type manifest: str
    :param type_: The reactor script type. Possible values are simple, bundle.
                  Default is simple
    :type type_: str
    :param api_key: The API key to authorize request against.
    :type api_key: str
    :return:
    """
    kwargs = locals()
    kwargs['type'] = kwargs.pop('type_')
    api_key = kwargs.pop('api_key', None)
    project_id = kwargs.pop('project_id')
    assertions.datatype_str('project_id', project_id)
    application_id = kwargs.pop('application_id')
    assertions.datatype_str('application_id', application_id)
    assertions.validate_field_specs(kwargs, reactor_script_field_specs)
    url = '/projects/{}/applications/{}/reactorScript'.format(
        project_id, application_id)
    return utils.request('PUT', url, data=kwargs, api_key=api_key)
示例#24
0
def create_project(name, description=None, startsAt=None, endsAt=None,
                   tags=None, shortDomains=None, customFields=None,
                   api_key=None):
    """
    Create a new Project.

    :param name:
    :type name: str
    :param description:
    :type description: str
    :param startsAt:
    :type startsAt: int
    :param endsAt:
    :type endsAt: int
    :param tags:
    :type tags: list of str
    :param shortDomains:
    :type shortDomains: list of str
    :param api_key:
    :type api_key: str
    :return A Project document.
    :rtype Response
    """
    kwargs = locals()
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    logger.debug('Creating Project...')
    return utils.request('POST', '/projects', data=kwargs, api_key=api_key)
示例#25
0
def update_location(thng, position=None, timestamp=None, api_key=None,
                    request_kwargs=None):
    data = {'position': position, 'timestamp': timestamp}
    assertions.validate_field_specs(data, field_specs)
    url = '/thngs/{}/location'.format(thng)
    return utils.request('PUT', url, data=data, api_key=api_key,
                         **(request_kwargs or {}))
示例#26
0
def update_user(user,
                email=None,
                firstName=None,
                lastName=None,
                password=None,
                birthday=None,
                gender=None,
                timezone=None,
                locale=None,
                photo=None,
                customFields=None,
                tags=None,
                api_key=None,
                request_kwargs=None):
    """Update an Application User."""
    kwargs = locals()
    del kwargs['request_kwargs']
    user = kwargs.pop('user')
    api_key = kwargs.pop('api_key', None)
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/users/{}'.format(user)
    return utils.request('PUT',
                         url,
                         data=kwargs,
                         api_key=api_key,
                         **(request_kwargs or {}))
示例#27
0
def update_collection(collection_id,
                      name=None,
                      description=None,
                      customFields=None,
                      collections=None,
                      tags=None,
                      api_key=None):
    """
    Update an existing Collection.

    :param collection_id: The Collection to update.
    :type collection_id: str
    :param name:
    :type description: str
    :param description:
    :type description: str
    :param customFields:
    :type customFields: list of str
    :param collections:
    :type collections: list of str
    :param tags:
    :type tags: list of str
    :param api_key:
    :type api_key: str
    :return
    :rtype
    """
    kwargs = locals()
    collection_id = kwargs.pop('collection_id')
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/collections/{}'.format(collection_id)
    return utils.request('PUT', url, data=kwargs, api_key=api_key)
示例#28
0
def create_device_thng(thng, thngApiKey, api_key=None, request_kwargs=None):
    assertions.datatype_str('thng', thng)
    assertions.datatype_str('thngApiKey', thngApiKey)
    data = {'thng': thng, 'thngApiKey': thngApiKey}
    return utils.request(
        'POST', '/auth/evrythng/thngs', data=data, api_key=api_key,
        **(request_kwargs or {}))
示例#29
0
def update_reactor(project_id, application_id, script=None, bundle=None, manifest=None,
                   api_key=None):
    """
    Update a Reactor Script.

    :param project_id: The Project of the Application.
    :type project_id: str
    :param application_id: The Application to update the Reactor script for.
    :type application_id: str
    :param script: The reactor script.
    :type script: str
    :param bundle: The reactor script bundle.
    :type bundle: dict
    :param manifest: The reactor script manifest.
    :type manifest: str
    :param api_key: The API key to authorize request against.
    :type api_key: str
    :return:
    """
    kwargs = locals()
    api_key = kwargs.pop('api_key', None)
    project_id = kwargs.pop('project_id')
    application_id = kwargs.pop('application_id')
    bundle = kwargs.pop('bundle', None)

    assertions.validate_field_specs(kwargs, reactor_field_specs)
    url = '/projects/{}/applications/{}/reactorScript'.format(project_id, application_id)

    return utils.request('PUT', url, data=None if bundle else kwargs, api_key=api_key, files=bundle)
示例#30
0
def delete_place(place, api_key=None, request_kwargs=None):
    assertions.datatype_str('place', place)
    url = '/places/{}'.format(place)
    return utils.request('DELETE',
                         url,
                         api_key=api_key,
                         **(request_kwargs or {}))
示例#31
0
def create_collection(name, description=None, customFields=None,
                      collections=None, tags=None, api_key=None,
                      request_kwargs=None):
    """
    Create a new Collection.

    :param name: The Name of the Collection.
    :type description: str
    :param description: The Description of the Collection.
    :type description: str
    :param customFields: The Custom Fields of Collection.
    :type customFields: dict
    :param collections: The Collections of the Collection.
    :type collections: list of str
    :param tags: The Tags of the Collection.
    :type tags: list of str
    :param api_key: The API key to authorize request against.
    :type api_key: str
    :return
    :rtype
    """
    kwargs = locals()
    del kwargs['request_kwargs']
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    return utils.request('POST', '/collections', data=kwargs, api_key=api_key,
                         **(request_kwargs or {}))
示例#32
0
def delete_location(thng, api_key=None, request_kwargs=None):
    assertions.datatype_str('thng', thng)
    url = '/thngs/{}/location'.format(thng)
    return utils.request('DELETE',
                         url,
                         api_key=api_key,
                         **(request_kwargs or {}))
示例#33
0
def create_project(name,
                   description=None,
                   startsAt=None,
                   endsAt=None,
                   tags=None,
                   shortDomains=None,
                   customFields=None,
                   api_key=None):
    """
    Create a new Project.

    :param name:
    :type name: str
    :param description:
    :type description: str
    :param startsAt:
    :type startsAt: int
    :param endsAt:
    :type endsAt: int
    :param tags:
    :type tags: list of str
    :param shortDomains:
    :type shortDomains: list of str
    :param api_key:
    :type api_key: str
    :return A Project document.
    :rtype Response
    """
    kwargs = locals()
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    logger.debug('Creating Project...')
    return utils.request('POST', '/projects', data=kwargs, api_key=api_key)
示例#34
0
def update_property_on_product(product_id, key, value, timestamp=None,
                               api_key=None):
    kwargs = locals()
    product_id = kwargs.pop('product_id')
    api_key = kwargs.pop('api_key')
    url = '/products/{}/properties'.format(product_id)
    return utils.request('PUT', url, data=kwargs, api_key=api_key)
示例#35
0
def create_thng(name, description=None, product=None, location=None,
                identifiers=None, properties=None, tags=None, collections=None,
                customFields=None, api_key=None):
    kwargs = locals()
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    return utils.request('POST', '/thngs', data=kwargs, api_key=api_key)
示例#36
0
def delete_user(user, api_key=None, request_kwargs=None):
    """Delete a User."""
    assertions.datatype_str('user', user)
    url = '/users/{}'.format(user)
    return utils.request('DELETE',
                         url,
                         api_key=api_key,
                         **(request_kwargs or {}))
示例#37
0
def list_thng_properties(thng_id, api_key=None):
    """List all Properties on a thng.

    TODO: add filtering capability.
    """
    assertions.datatype_str('thng_id', thng_id)
    url = '/thngs/{}/properties'.format(thng_id)
    return utils.request('GET', url, api_key=api_key)
示例#38
0
def list_product_properties(product_id, api_key=None):
    """List all Properties on a Product.

    TODO: add filtering capability.
    """
    assertions.datatype_str('product_id', product_id)
    url = '/products/{}/properties'.format(product_id)
    return utils.request('GET', url, api_key=api_key)
def create_user(email, firstName=None, lastName=None, password=None,
                birthday=None, gender=None, timezone=None, locale=None,
                photo=None, customFields=None, tags=None, api_key=None):
    kwargs = locals()
    api_key = kwargs.pop('api_key', None)
    assertions.validate_field_specs(kwargs, field_specs)
    return utils.request(
        'POST', '/auth/evrythng/users', data=kwargs, api_key=api_key)
def list_product_properties(product,
                            from_date=None,
                            to_date=None,
                            **request_kwargs):
    """List all Properties on a Product."""
    assertions.datatype_str('product', product)
    url = '/products/{}/properties'.format(product)
    return utils.request('GET', url, **request_kwargs)
示例#41
0
def read_thng(thng, api_key=None, request_kwargs=None):
    assertions.datatype_str('thng', thng)
    url = '/thngs/{}'.format(thng)
    return utils.request('GET',
                         url,
                         api_key=api_key,
                         accept=True,
                         **(request_kwargs or {}))
def create_device_thng(thng, thngApiKey, api_key=None):
    assertions.datatype_str('thng', thng)
    assertions.datatype_str('thngApiKey', thngApiKey)
    data = {'thng': thng, 'thngApiKey': thngApiKey}
    return utils.request('POST',
                         '/auth/evrythng/thngs',
                         data=data,
                         api_key=api_key)
示例#43
0
def update_place(place_id, name=None, position=None, address=None, description=None,
                 icon=None, tags=None, customFields=None):
    kwargs = locals()
    place_id = kwargs.pop('place_id')
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/places/{}'.format(place_id)
    return utils.request('PUT', url, data=kwargs, api_key=api_key)
示例#44
0
def read_collection_actions(collection,
                            type_,
                            api_key=None,
                            request_kwargs=None):
    """Read Actions for a Collection."""
    assertions.datatype_str('collection', collection)
    assertions.datatype_str('type_', type_)
    url = '/collections/{}/actions/{}'.format(collection, type_)
    return utils.request('GET', url, api_key=api_key, **(request_kwargs or {}))
示例#45
0
def list_thng_properties(thng,
                         from_date=None,
                         to_date=None,
                         api_key=None,
                         request_kwargs=None):
    """List all Properties on a thng."""
    assertions.datatype_str('thng', thng)
    url = '/thngs/{}/properties'.format(thng)
    return utils.request('GET', url, api_key=api_key, **(request_kwargs or {}))
def authenticate_facebook_user(expires, token, api_key=None):
    assertions.datatype_str('token', token)
    data = {
        'access': {
            'expires': expires,
            'token': token,
        }
    }
    return utils.request('POST', '/auth/facebook', data=data, api_key=api_key)
示例#47
0
def update_product(product_id, name=None, description=None, brand=None,
                   categories=None, photos=None, url=None, identifiers=None,
                   properties=None, tags=None, customFields=None, api_key=None):
    kwargs = locals()
    product_id = kwargs.pop('product_id')
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/products/{}'.format(product_id)
    return utils.request('PUT', url, data=kwargs, api_key=api_key)
示例#48
0
def delete_action(type_, action, api_key=None, request_kwargs=None):
    """Delete an Action"""
    assertions.datatype_str('type_', type_)
    assertions.datatype_str('action', action)
    url = '/actions/{}/{}'.format(type_, action)
    return utils.request('DELETE',
                         url,
                         api_key=api_key,
                         **(request_kwargs or {}))
示例#49
0
def login_user(email, password, app_api_key):
    """Login an Application User."""
    kwargs = locals()
    app_api_key = kwargs.pop('app_api_key', None)
    assertions.validate_field_specs(kwargs, field_specs)
    return utils.request('POST',
                         '/auth/evrythng',
                         data=kwargs,
                         api_key=app_api_key)
示例#50
0
def update_action_type(name, customFields=None, tags=None, scopes=None,
                       api_key=None):
    kwargs = locals()
    kwargs['type'] = kwargs['type_']
    del kwargs['type_']
    api_key = kwargs.pop('api_key', None)
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/actions/{}'.format(type_)
    return utils.request('POST', '/actions', data=kwargs, api_key=api_key)
示例#51
0
def create_place(name, position=None, address=None, description=None,
                 icon=None, tags=None, customFields=None, api_key=None,
                 request_kwargs=None):
    kwargs = locals()
    del kwargs['request_kwargs']
    api_key = kwargs.pop('api_key')
    assertions.validate_field_specs(kwargs, field_specs)
    return utils.request('POST', '/places', data=kwargs, api_key=api_key,
                         **(request_kwargs or {}))
def authenticate_facebook_user(expires, token, api_key=None):
    assertions.datatype_str('token', token)
    data = {
        'access': {
            'expires': expires,
            'token': token,
        }
    }
    return utils.request('POST', '/auth/facebook', data=data, api_key=api_key)
示例#53
0
def update_action_type(name, customFields=None, tags=None, scopes=None,
                       api_key=None, request_kwargs=None):
    """Update an Action Type"""
    kwargs = locals()
    del kwargs['request_kwargs']
    api_key = kwargs.pop('api_key', None)
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/actions/{}'.format(name)
    return utils.request('POST', '/actions', data=kwargs, api_key=api_key,
                         **(request_kwargs or {}))
示例#54
0
def update_thng(thng_id, name=None, description=None, product=None,
                location=None, identifiers=None, properties=None, tags=None,
                collections=None, customFields=None, api_key=None):
    kwargs = locals()
    api_key = kwargs.pop('api_key')
    thng_id = kwargs.pop('thng_id')
    assertions.validate_field_specs(kwargs, field_specs)
    url = '/thngs/{}'.format(thng_id)
    return utils.request(
        'PUT', url, data=kwargs, api_key=api_key)