Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.
Sunti edited this page Mar 31, 2019 · 9 revisions

cryptic-device

Python MicroService for the community project Cryptic-Device

There are two types of models:

Device:

Explanation of data keys:
  1. user_uuid is the unique identifier for a user account in the game.
  2. device_uuid is the unique identifier for a device.
  3. name is the new name for changing a device's name.
There are two types of endpoints:
/public                # The endpoint every user has access to
    /<string:uuid>     # The device's uuid
        /info          # Get information about a device -> device.serialize
        /ping          # Ping a device -> device.powered_on
/private               # The endpoint only the owner has access to
    /<string:uuid>     # The device's uuid
        /info          # Get private information about the device -> device.serialize
        /power         # Turn the device on/off
        /name          # Change the name of the device
        /remove        # Delete a device
    /all               # Get a list of all devices
    /create            # Create a device

File:

Explanation of data keys:
  1. user_uuid is the unique identifier for a user account in the game.
  2. device_uuid is the unique identifier for a device.
  3. file_uuid is the unique identifier for a file of a device.
  4. filename is for creating and updating a file.
  5. content is also for creating and updating a file.
Explanation of endpoints:
/<string:device>        # Endpoint that doesn't require a file uuid
    /<string:uuid>      # Endpoint that requires uuid
        /info           # Get information about a file
        /update         # Update a file
        /remove         # Delete a file
    /all                # Get all files of a device
    /create             # Create a new file

Let's talk about the endpoints:

The first part of the endpoint is either device or file, depending on what you want.

If you want device you now have to choose between public and private.

If you chose public, the next part of the endpoint has to be a device uuid.

Then you have 2 options:

  • The endpoint info provides you information about the device.

input:

{"device_uuid": "aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14"}  # The device uuid from 3.

returns:

{
    'powered_on': True, 
    'owner': '89f83474-4b65-4467-9bf8-8129d60e3e19',  # The owner
    'uuid': 'aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14', 
    'power': 1, 
    'name': 'kore'
}
  • The The endpoint ping shows if a device is online.

input:

{"device_uuid": "aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14"}  # The device uuid from 3.

returns:

{'online': True}

If you chose private you have 2 options.

The next part of the endpoint is either a device uuid, all or create.

The endpoint all returns a list of all devices of a user.

input:

{"user_uuid": "89f83474-4b65-4467-9bf8-8129d60e3e19"}  # The user uuid from your data

returns:

{
    'devices': [{
        'powered_on': True, 
        'owner': '89f83474-4b65-4467-9bf8-8129d60e3e19', 
        'uuid': 'aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14', 
        'power': 1, 
        'name': 'kore'
    }]
}

The endpoint create creates a new device.

input:

{"user_uuid": "89f83474-4b65-4467-9bf8-8129d60e3e19"}  # The user uuid from your data

returns:

{
    'powered_on': True, 
    'owner': '89f83474-4b65-4467-9bf8-8129d60e3e19', 
    'uuid': 'f817ded2-8f6c-4b58-a5f9-819047d7ff6d', 
    'power': 1, 
    'name': 'dogmatix'
}

If the endpoint is a user uuid you have 4 options.

The endpoint info provides you private information about a device.

input:

{
    'device_uuid': 'aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14', 
    'user_uuid': '89f83474-4b65-4467-9bf8-8129d60e3e19'
}

returns:

{
    'powered_on': True, 
    'owner': '89f83474-4b65-4467-9bf8-8129d60e3e19', 
    'uuid': 'aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14', 
    'power': 1, 
    'name': 'kore'
}

The endpoint power turns a device on/off.

input:

{
    'device_uuid': 'aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14', 
    'user_uuid': '89f83474-4b65-4467-9bf8-8129d60e3e19'
}

returns:

{
    'powered_on': False, 
    'owner': '89f83474-4b65-4467-9bf8-8129d60e3e19', 
    'uuid': 'aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14', 
    'power': 1, 
    'name': 'kore'
}

The endpoint name changes the name of a device.

input:

{
    'device_uuid': 'aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14', 
    'user_uuid': '89f83474-4b65-4467-9bf8-8129d60e3e19',
    'name': 'quint'
}

returns:

{
    'powered_on': True, 
    'owner': '89f83474-4b65-4467-9bf8-8129d60e3e19', 
    'uuid': 'aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14', 
    'power': 1, 
    'name': 'quint'
}

The endpoint remove deletes the device

input:

{
    'device_uuid': 'aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14', 
    'user_uuid': '89f83474-4b65-4467-9bf8-8129d60e3e19'
}

returns:

{'ok': True}

If you want the file your next part of the endpoint is a device uuid

...

Clone this wiki locally