Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.
Sunti edited this page Apr 3, 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.
Explanation of endpoints:
# Endpoints for user

/info          # Get information about a device -> device.serialize
/ping          # Ping a device -> device.powered_on
/power         # Turn the device on/off
/change_name   # Change the name of the device
/delete        # Delete a device
/all           # Get a list of all devices
/create        # Create a device

# Endpoints for microservices

/exist         # Returns if a device exists

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:
# Endpoints for user

/info           # Get information about a file
/update         # Update a file
/delete         # 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 7 endpoints.

  • The endpoint info provides you information about the device.

input:

{"device_uuid": "aa84a1ea-fd42-4cd0-a5ca-0bc9388d9b14"}

returns:

{
    'powered_on': True, 
    'owner': '89f83474-4b65-4467-9bf8-8129d60e3e19',
    '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"}

returns:

{'online': True}
  • 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'
}
  • 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 change_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 delete 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 you have to chose between 5 endpoints.

  • If you chose create the input data looks like this:

input:

{
    'user_uuid': '89f83474-4b65-4467-9bf8-8129d60e3e19', 
    'device_uuid': '366a52a1-4f02-4087-a164-7c81a443b7d3', 
    'filename': 'cryptic', 
    'content': 'the best'
}

returns:

{
    'device': '366a52a1-4f02-4087-a164-7c81a443b7d3', 
    'filename': 'cryptic', 
    'uuid': '3fa20793-41cf-4508-bf54-476acc8b4c23', 
    'content': 'the best'
}
  • If you chose all your input and output looks like this:

input:

{
    'user_uuid': '89f83474-4b65-4467-9bf8-8129d60e3e19', 
    'device_uuid': '366a52a1-4f02-4087-a164-7c81a443b7d3', 
    'filename': 'cryptic', 
    'content': 'the best'
}

returns:

{
    'files': [{
        'device': '366a52a1-4f02-4087-a164-7c81a443b7d3', 
        'content': 'the best', 
        'uuid': '3fa20793-41cf-4508-bf54-476acc8b4c23', 
        'filename': 'cryptic'
    }]
}
  • The endpoint info gives you some information about the file.

input:

{
    'user_uuid': '89f83474-4b65-4467-9bf8-8129d60e3e19', 
    'device_uuid': '366a52a1-4f02-4087-a164-7c81a443b7d3', 
    'filename': 'cryptic', 
    'content': 'the best', 
    'file_uuid': '718a808a-4001-46d1-9c36-b036f06d110e'
}

returns:

{
    'device': '366a52a1-4f02-4087-a164-7c81a443b7d3', 
    'content': 'the best', 
    'uuid': '718a808a-4001-46d1-9c36-b036f06d110e', 
    'filename': 'cryptic'
}
  • The endpoint removes deletes a file:

input:

{
    'user_uuid': '89f83474-4b65-4467-9bf8-8129d60e3e19', 
    'device_uuid': '366a52a1-4f02-4087-a164-7c81a443b7d3', 
    'filename': 'cryptic', 
    'content': 'the best', 
    'file_uuid': '718a808a-4001-46d1-9c36-b036f06d110e'
}

returns:

{'ok': True}
  • The endpoint update updates a file:

input:

{
    'user_uuid': '9ec72068-5d62-45d5-bedf-612794ae6988', 
    'device_uuid': '42e4d805-c627-413c-98d0-b618ae7e1754', 
    'filename': 'new', 
    'content': 'the better one', 
    'file_uuid': '694f8bf2-b38e-4b0e-8266-b8c6864ab824'
}

returns:

{
    'device': '42e4d805-c627-413c-98d0-b618ae7e1754', 
    'content': 'the better one', 
    'uuid': '694f8bf2-b38e-4b0e-8266-b8c6864ab824', 
    'filename': 'new'
}

If something goes wrong, try to print the ['error'] of the response.

Clone this wiki locally