async def master_create(request: web.Request) -> web.Response: """ --- summary: Create a master remote tags: - Spark - Remote operationId: controller.spark.remote.master produces: - application/json parameters: - in: body name: body description: subscription required: true schema: type: object properties: id: type: string example: local_sensor_1 interval: type: int example: 5 """ request_args = await request.json() with utils.collecting_input(): args = ( request_args['id'], request_args['interval'], ) return web.json_response( await RemoteApi(request.app).add_master(*args) )
async def object_create(request: web.Request) -> web.Response: """ --- summary: Create object tags: - Spark - Objects operationId: controller.spark.objects.create produces: - application/json parameters: - in: body name: body description: object required: true schema: type: object properties: id: type: string example: temp_sensor_1 nid: type: int required: false example: 0 groups: type: array example: [0, 3, 4] type: type: string example: TempSensorOneWire data: type: object example: { "address": "FF", "offset[delta_degF]": 20, "value": 200 } """ request_args = await request.json() with utils.collecting_input(): args = ( request_args[API_SID_KEY], request_args.get(API_NID_KEY), request_args[GROUP_LIST_KEY], request_args[API_TYPE_KEY], request_args[API_DATA_KEY], ) return web.json_response(await ObjectApi(request.app).create(*args))
async def object_write(request: web.Request) -> web.Response: """ --- summary: Update object tags: - Spark - Objects operationId: controller.spark.objects.update produces: - application/json parameters: - name: id in: path required: true description: Service ID of object schema: type: string - name: body in: body description: object required: true schema: type: object properties: groups: type: list example: [0, 4, 8] type: type: string example: TempSensorOneWire data: type: object example: { "address": "FF", "offset[delta_degF]": 20, "value": 200 } """ request_args = await request.json() with utils.collecting_input(): args = ( request.match_info[API_SID_KEY], request_args[GROUP_LIST_KEY], request_args[API_TYPE_KEY], request_args[API_DATA_KEY], ) return web.json_response(await ObjectApi(request.app).write(*args))
async def slave_create(request: web.Request) -> web.Response: """ --- summary: Create a slave remote tags: - Spark - Remote operationId: controller.spark.remote.slave produces: - application/json parameters: - in: body name: body description: subscription required: true schema: type: object properties: id: type: string example: local_sensor_1 key: type: string example: remote_sensor_couple_1 translations: type: object example: { "value": "targetvalue", "nested/value": "nested/target/value" } """ request_args = await request.json() with utils.collecting_input(): args = ( request_args['id'], request_args['key'], request_args['translations'], ) return web.json_response( await RemoteApi(request.app).add_slave(*args) )
async def alias_update(request: web.Request) -> web.Response: """ --- summary: Update existing alias tags: - Spark - Aliases operationId: controller.spark.aliases.update produces: - application/json parameters: - name: id in: path required: true schema: type: int - in: body name: body description: alias required: true schema: type: object properties: id: type: str example: onewirebus required: true """ with utils.collecting_input(): args = ( request.match_info[API_SID_KEY], (await request.json())[API_SID_KEY], ) return web.json_response( await AliasApi(request.app).update(*args) )
async def alias_create(request: web.Request) -> web.Response: """ --- summary: Create new alias tags: - Spark - Aliases operationId: controller.spark.aliases.create produces: - application/json parameters: - in: body name: body description: alias required: true schema: type: object properties: sid: type: str example: onewirebus required: true controller_id: type: int example: 2 required: true """ request_args = await request.json() with utils.collecting_input(): args = ( request_args['sid'], request_args['controller_id'], ) return web.json_response( await AliasApi(request.app).create(*args) )
async def alias_delete(request: web.Request) -> web.Response: """ --- summary: Delete existing alias tags: - Spark - Aliases operationId: controller.spark.aliases.delete produces: - application/json parameters: - name: id in: path required: true schema: type: int """ with utils.collecting_input(): id = request.match_info[API_SID_KEY] return web.json_response( await AliasApi(request.app).delete(id) )