cloudio-glue-python


Namecloudio-glue-python JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://cloudio.hevs.ch
Summarycloud.iO endpoint glue
upload_time2023-07-26 09:29:56
maintainer
docs_urlNone
authorHES-SO Valais, School of Engineering, Sion
requires_python
licenseMIT
keywords cloud.io endpoint library iot cloud connector model
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # Cloud.iO Glue

![python-version](https://img.shields.io/badge/python-3.x-blue.svg?style=flat)

![version](https://img.shields.io/pypi/v/cloudio-glue-python.svg)

![](docs/images/coverage.svg)





## Introduction

This package is an extension to the 

[cloudio-endpoint-python](https://github.com/cloudio-project/cloudio-endpoint-python) 

package providing features not present in the 

[java-endpoint](https://github.com/cloudio-project/cloudio-endpoint-java)

implementation.

It supports the developer with the `Model2CloudConnector` class and the 

'cloudio_attribute' decorator.



The fast and simple solution to connect an object to the cloud is to inherit 

the class from `CloudioNode` and automatically all attributes get

synchronized to the cloud. The drawback here is that the developer does not

have the choice to prohibit the synchronisation of some attributes.



There is where the `Model2CloudConnector` class comes in. Inheriting from this

class allows specifying which attribute should be synchronized to the cloud

using the `attribute mapping` feature.



## Download and Install

The library is available on python's package distribution system [PyPi](https://pypi.python.org/).



From the console you can download and install it using the following command:



```

   pip install cloudio-glue-python

```



## Model2CloudConnector Class

The `Model2CloudConnector` class allows to synchronise some attributes of a class.

Which attributes to synchronise is done with an attribute mapping.



To use the `Model2CloudConnector` class you need to inherit from it and then

specify which of the attributes to synchronize using the `set_attribute_mapping()`

method. 



### Attribute Mapping

Here is an example on how to bring attributes (or properties) `x` and `y` of the

`ComputerMouse` class to the cloud:



```python

from cloudio.glue import Model2CloudConnector    



class ComputerMouse(Model2CloudConnector):



    def __init__(self):

        super(ComputerMouse, self).__init__()

        self._x = 0

        self._y = 0



        # Define the attributes which are going to be mapped to cloud.iO

        self.set_attribute_mapping({'x': {'topic': 'position.x', 'attributeType': float,

                                          'constraints': ('read',)},  # ('read', 'write')

                                    'y': {'topic': 'position.y', 'attributeType': float,

                                          'constraints': ('read',)},

                                })



    @property

    def x(self): return self._x



    @x.setter

    def x(self, value): self._x = value

    

    @property

    def y(self): return self._y



    @y.setter

    def y(self, value): self._y = value

```



### Attribute Access Policy

For each attribute the access policy can be specified. Following values can be given

 - read

 - write



or both. 



The **read** access policy allows to read the attribute from the cloud. Giving the

**write** access policy allows to change the attribute via the cloud.



## cloudio_attribute Decorator

An attribute can be automatically synchronized to the cloud by assigning

the `cloudio_attribute` decorator to the property.



To assign for example the decorator to the x property change the code above as follows. Remove

the @property decorator and replace it with the `@cloudio_attribute` decorator.



The example below shows the `@cloudio_attribute` decorator applied to the `x` and `y` property:



```python

from cloudio.glue import Model2CloudConnector

from cloudio.glue import cloudio_attribute



class ComputerMouse(Model2CloudConnector):



    def __init__(self):

        super(ComputerMouse, self).__init__()



        self._x = 0

        self._y = 0



        # Define the attributes which are going to be mapped to cloud.iO

        self.set_attribute_mapping({'x': {'topic': 'position.x', 'attributeType': float,

                                          'constraints': ('read',)},  # ('read', 'write')

                                    'y': {'topic': 'position.y', 'attributeType': float,

                                          'constraints': ('read',)},

                                    })



    @cloudio_attribute

    def x(self): return self._x



    @x.setter

    def x(self, value): self._x = value



    @cloudio_attribute

    def y(self): return self._y



    @y.setter

    def y(self, value): self._y = value

```



Now every time the `x` or `y` property gets changed, the value is automatically updated to the cloud.


            

Raw data

            {
    "_id": null,
    "home_page": "https://cloudio.hevs.ch",
    "name": "cloudio-glue-python",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "cloud.iO endpoint library IoT cloud connector model",
    "author": "HES-SO Valais, School of Engineering, Sion",
    "author_email": "thomas.sterren@hevs.ch",
    "download_url": "https://files.pythonhosted.org/packages/b8/96/229425677e2ded021adf0b048a00ea2bfd55fa7402b703440b15d95035b1/cloudio-glue-python-1.0.3.tar.gz",
    "platform": null,
    "description": "# Cloud.iO Glue\r\n\r\n![python-version](https://img.shields.io/badge/python-3.x-blue.svg?style=flat)\r\n\r\n![version](https://img.shields.io/pypi/v/cloudio-glue-python.svg)\r\n\r\n![](docs/images/coverage.svg)\r\n\r\n\r\n\r\n\r\n\r\n## Introduction\r\n\r\nThis package is an extension to the \r\n\r\n[cloudio-endpoint-python](https://github.com/cloudio-project/cloudio-endpoint-python) \r\n\r\npackage providing features not present in the \r\n\r\n[java-endpoint](https://github.com/cloudio-project/cloudio-endpoint-java)\r\n\r\nimplementation.\r\n\r\nIt supports the developer with the `Model2CloudConnector` class and the \r\n\r\n'cloudio_attribute' decorator.\r\n\r\n\r\n\r\nThe fast and simple solution to connect an object to the cloud is to inherit \r\n\r\nthe class from `CloudioNode` and automatically all attributes get\r\n\r\nsynchronized to the cloud. The drawback here is that the developer does not\r\n\r\nhave the choice to prohibit the synchronisation of some attributes.\r\n\r\n\r\n\r\nThere is where the `Model2CloudConnector` class comes in. Inheriting from this\r\n\r\nclass allows specifying which attribute should be synchronized to the cloud\r\n\r\nusing the `attribute mapping` feature.\r\n\r\n\r\n\r\n## Download and Install\r\n\r\nThe library is available on python's package distribution system [PyPi](https://pypi.python.org/).\r\n\r\n\r\n\r\nFrom the console you can download and install it using the following command:\r\n\r\n\r\n\r\n```\r\n\r\n   pip install cloudio-glue-python\r\n\r\n```\r\n\r\n\r\n\r\n## Model2CloudConnector Class\r\n\r\nThe `Model2CloudConnector` class allows to synchronise some attributes of a class.\r\n\r\nWhich attributes to synchronise is done with an attribute mapping.\r\n\r\n\r\n\r\nTo use the `Model2CloudConnector` class you need to inherit from it and then\r\n\r\nspecify which of the attributes to synchronize using the `set_attribute_mapping()`\r\n\r\nmethod. \r\n\r\n\r\n\r\n### Attribute Mapping\r\n\r\nHere is an example on how to bring attributes (or properties) `x` and `y` of the\r\n\r\n`ComputerMouse` class to the cloud:\r\n\r\n\r\n\r\n```python\r\n\r\nfrom cloudio.glue import Model2CloudConnector    \r\n\r\n\r\n\r\nclass ComputerMouse(Model2CloudConnector):\r\n\r\n\r\n\r\n    def __init__(self):\r\n\r\n        super(ComputerMouse, self).__init__()\r\n\r\n        self._x = 0\r\n\r\n        self._y = 0\r\n\r\n\r\n\r\n        # Define the attributes which are going to be mapped to cloud.iO\r\n\r\n        self.set_attribute_mapping({'x': {'topic': 'position.x', 'attributeType': float,\r\n\r\n                                          'constraints': ('read',)},  # ('read', 'write')\r\n\r\n                                    'y': {'topic': 'position.y', 'attributeType': float,\r\n\r\n                                          'constraints': ('read',)},\r\n\r\n                                })\r\n\r\n\r\n\r\n    @property\r\n\r\n    def x(self): return self._x\r\n\r\n\r\n\r\n    @x.setter\r\n\r\n    def x(self, value): self._x = value\r\n\r\n    \r\n\r\n    @property\r\n\r\n    def y(self): return self._y\r\n\r\n\r\n\r\n    @y.setter\r\n\r\n    def y(self, value): self._y = value\r\n\r\n```\r\n\r\n\r\n\r\n### Attribute Access Policy\r\n\r\nFor each attribute the access policy can be specified. Following values can be given\r\n\r\n - read\r\n\r\n - write\r\n\r\n\r\n\r\nor both. \r\n\r\n\r\n\r\nThe **read** access policy allows to read the attribute from the cloud. Giving the\r\n\r\n**write** access policy allows to change the attribute via the cloud.\r\n\r\n\r\n\r\n## cloudio_attribute Decorator\r\n\r\nAn attribute can be automatically synchronized to the cloud by assigning\r\n\r\nthe `cloudio_attribute` decorator to the property.\r\n\r\n\r\n\r\nTo assign for example the decorator to the x property change the code above as follows. Remove\r\n\r\nthe @property decorator and replace it with the `@cloudio_attribute` decorator.\r\n\r\n\r\n\r\nThe example below shows the `@cloudio_attribute` decorator applied to the `x` and `y` property:\r\n\r\n\r\n\r\n```python\r\n\r\nfrom cloudio.glue import Model2CloudConnector\r\n\r\nfrom cloudio.glue import cloudio_attribute\r\n\r\n\r\n\r\nclass ComputerMouse(Model2CloudConnector):\r\n\r\n\r\n\r\n    def __init__(self):\r\n\r\n        super(ComputerMouse, self).__init__()\r\n\r\n\r\n\r\n        self._x = 0\r\n\r\n        self._y = 0\r\n\r\n\r\n\r\n        # Define the attributes which are going to be mapped to cloud.iO\r\n\r\n        self.set_attribute_mapping({'x': {'topic': 'position.x', 'attributeType': float,\r\n\r\n                                          'constraints': ('read',)},  # ('read', 'write')\r\n\r\n                                    'y': {'topic': 'position.y', 'attributeType': float,\r\n\r\n                                          'constraints': ('read',)},\r\n\r\n                                    })\r\n\r\n\r\n\r\n    @cloudio_attribute\r\n\r\n    def x(self): return self._x\r\n\r\n\r\n\r\n    @x.setter\r\n\r\n    def x(self, value): self._x = value\r\n\r\n\r\n\r\n    @cloudio_attribute\r\n\r\n    def y(self): return self._y\r\n\r\n\r\n\r\n    @y.setter\r\n\r\n    def y(self, value): self._y = value\r\n\r\n```\r\n\r\n\r\n\r\nNow every time the `x` or `y` property gets changed, the value is automatically updated to the cloud.\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "cloud.iO endpoint glue",
    "version": "1.0.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/boozo-unlimited/cloudio-glue-python/issues",
        "Documentation": "https://github.com/boozo-unlimited/cloudio-glue-python#cloudio-glue",
        "Homepage": "https://cloudio.hevs.ch",
        "Source Code": "https://github.com/boozo-unlimited/cloudio-glue-python"
    },
    "split_keywords": [
        "cloud.io",
        "endpoint",
        "library",
        "iot",
        "cloud",
        "connector",
        "model"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a12b339717f0cf39b66a25cc2743f229bbb6adbb04ef65e81a1576d9ae210740",
                "md5": "2e4959694bd2ee497e3ae2215e404ea9",
                "sha256": "b8644f539ee7f16260bc7aa10833d418ae8d19d90793d5cff3d4871a88e9828b"
            },
            "downloads": -1,
            "filename": "cloudio_glue_python-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2e4959694bd2ee497e3ae2215e404ea9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10868,
            "upload_time": "2023-07-26T09:29:42",
            "upload_time_iso_8601": "2023-07-26T09:29:42.108728Z",
            "url": "https://files.pythonhosted.org/packages/a1/2b/339717f0cf39b66a25cc2743f229bbb6adbb04ef65e81a1576d9ae210740/cloudio_glue_python-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b896229425677e2ded021adf0b048a00ea2bfd55fa7402b703440b15d95035b1",
                "md5": "0b278ebbb006f80e42fd0d45caa9aaaf",
                "sha256": "c3c4257242b59005b70e599dde4d73f5907666b9b243babd411269c3ea587aa9"
            },
            "downloads": -1,
            "filename": "cloudio-glue-python-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "0b278ebbb006f80e42fd0d45caa9aaaf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13640,
            "upload_time": "2023-07-26T09:29:56",
            "upload_time_iso_8601": "2023-07-26T09:29:56.431898Z",
            "url": "https://files.pythonhosted.org/packages/b8/96/229425677e2ded021adf0b048a00ea2bfd55fa7402b703440b15d95035b1/cloudio-glue-python-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-26 09:29:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "boozo-unlimited",
    "github_project": "cloudio-glue-python",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "lcname": "cloudio-glue-python"
}
        
Elapsed time: 0.09819s