Skip to main content

A Django model to manage Fiware Orion Entities as local models

Project description

A Django App to manage a [Fiware Orion ](https://github.com/telefonicaid/fiware-orion) context broker entities as Django Model Objects.
## Install

In order to intall simply use pip

```
pip install django_orion_model
```

## Usage

Simply add django_orion_model to your settings.py:

```python
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
...
'django_orion_model',
...
]

ORION_URL = "https://yourorion:1234"
ORION_SCOPE = "/desiredscope"
ORION_EXPIRATION = 200 // living time of local values
```

To define a Entity Model simply define a class in your models.py Using OrionEntity as Class father and use Orion fields to properties expected to live in the context broker.

```python
from django_orion_model import OrionEntityi

class WasteManagementStage(OrionEntity):
name = OrionCharField("name", max_length=1024, blank=True)
description = OrionTextField("description", max_length=1024, blank=True)
```

Available Field types for Orion Context ContextBroker:

* OrionCharField
* OrionTextField
* OrionFloatField
* OrionDateTimeField

An orion entity have a Default Field to manage Communication With Orion:

* context_broker(ForeingKey-ContextBroker): The Orion Context ContextBroker that manages the entity
* service_path(ForeingKey-Scope): The service-path where the entity lies.
* orion_id(CharField): The ID of the entity in Orion.
* type(CharField): The type of the entity in Orion.
* data(JSONField): A local repository of the last known values of the entity.
* updated(ArrayField-CharField): The name of the Orion field updates since las connection.
* expiration(DateTimeField): The time when the local data is considered obsolete.
* status(CharField): A predefined text that indicates the communication. Expected values:
* OK Everything is OK and up to date
* OFFLINE Set to Disable communication to Orion
* MISSING Indicates that the Entity not exist in Orion
* CREATING Set to Create the entity into Orion.
* CREATED Indicates that the entity is created but is values are not yet pulled from Orion(Transitory)
* PENDING_WRITING Indicates that the entity is performing a push to Orion(Transitory).
* PENDING_READING Indicates that the entity is performing a pull to Orion(Transitory).
* AWAIT_REFRESH The pull has failed and the entity is expecting a new opportunity to retry.
* AWAIT_REWRITING The push has failed and the entity is expecting a new opportunity to retry.
* error(TextField): IF the connection have a problem the Orion response is stored here.

## Entity Behaivour

The entity is expected to pull values from Orion after its creation, when an orion attributes is read and expiration time is up, before saving to database and after values are updated to orion.
The entity is expected to push values to Orion after a Orion values is Set.

Some status Values forces Some behavior:

* OFFLINE Set to Disable communication to Orion
* CREATING Set to Create the entity into Orion.

----

This library is partially funded by the [Waste4Think proyect](http://waste4think.eu/) that has received funding from the European Union’s [Horizon 2020](https://ec.europa.eu/programmes/horizon2020/) research and innovation program under grant agreement 688995.
The dissemination of results herein reflects only the author’s view and the European Commission is not responsible for any use that may be made of the information it contains.



Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-orion-model-0.4.1.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_orion_model-0.4.1-py2.py3-none-any.whl (13.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-orion-model-0.4.1.tar.gz.

File metadata

  • Download URL: django-orion-model-0.4.1.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.9.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.2

File hashes

Hashes for django-orion-model-0.4.1.tar.gz
Algorithm Hash digest
SHA256 ac052f131d2148729e9ab8f6e5c4ca0a5d4e80bf3cfd5de2b95bf9ad5e8dab93
MD5 178fe6f2608d7ae7ee6b5a2c141fafeb
BLAKE2b-256 e3264746848b64b0a4515b7e138ac9f78af209e9f53f8a2db5de7613391a1ea5

See more details on using hashes here.

File details

Details for the file django_orion_model-0.4.1-py2.py3-none-any.whl.

File metadata

  • Download URL: django_orion_model-0.4.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.9.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.2

File hashes

Hashes for django_orion_model-0.4.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0f020e59e23981fe752e465f11a7ee421ddf8831ce5b77c23bb54094caeecea7
MD5 36ffc5f3398ebbd7e30d5af8b4043653
BLAKE2b-256 2ff7cb70897474d5e3dfc0bba8fc3234485595812b09fd400864bd71f2419cd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page