#%RAML 0.8
title: WWST Thermostat Operational State
version: v1.0.0-20170918
schemas:
- Operation: |
    {
      "id": "http://openinterconnect.org/iotdatamodels/schemas/x.com.st.operationalstate.thermostat.json#",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description" : "Copyright (c) 2016, 2017 Open Connectivity Foundation, Inc. All rights reserved.",
      "title": "Thermostat Operational State",
      "definitions": {
    "x.com.st.operationalstate.thermostat": {
      "type": "object",
      "properties": {
        "jobStates": {
          "type": "array",
          "readOnly": true,
          "description": "array of the possible job states.",
          "items": {
            "type": "string"
          }
        },
        "currentJobState": {
          "type": "string",
          "description": "Currently active jobState"
        },
        "machineStates": {
          "type": "array",
          "readOnly": true,
          "description": "array of the possible currentMachineState.",
          "items": {
            "type": "string"
          }
        },
        "currentMachineState": {
          "type": "string",
          "description": "Currently active currentMachineState"
        },
        "startingTime": {
          "type": "integer",
          "description": "Start time in the current operational state"
        },
        "endingTime": {
          "type": "integer",
          "description": "End time in the current operational state"
        }
      }
    }
      },
      "type": "object",
      "allOf": [
    {"$ref": "oic.baseResource.json#/definitions/oic.r.baseresource"},
    {"$ref": "#/definitions/x.com.st.operationalstate.thermostat"}
      ],
      "required": [
        "jobStates","currentJobState","machineStates","currentMachineState"
      ]
    }
- OperationUpdate: |
    {
      "id": "http://openinterconnect.org/iotdatamodels/schemas/x.com.st.operationalstate.thermostat.json#",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description" : "Copyright (c) 2016, 2017 Open Connectivity Foundation, Inc. All rights reserved.",
      "title": "Thermostat Operational State Update",
      "definitions": {
    "x.com.st.operationalstate.thermostat": {
      "type": "object",
      "properties": {
        "currentMachineState": {
          "type": "string",
          "description": "Currently active currentMachineState"
        },
        "startingTime": {
          "type": "integer",
          "description": "Start time in the current operational state"
        },
        "endingTime": {
          "type": "integer",
          "description": "End time in the current operational state"
        }
      }
    }
      },
      "type": "object",
      "allOf": [
    {"$ref": "oic.baseResource.json#/definitions/oic.r.baseresource"},
    {"$ref": "#/definitions/x.com.st.operationalstate.thermostat"}
      ],
      "required": ["currentMachineState"]
    }

traits:
  - interface:
      queryParameters:
        if:
          enum: ["oic.if.s","oic.if.a","oic.if.baseline"]

/WWSTThermostatOperationalStateResURI:
  description: |
        Check and manipulate the operational and job states of a device
  displayName: WWST Thermostat Operational State
  is: [ interface ]

  get:
    description: |
      Retrieves the current thermostat operational state
    responses:
      200:
        body:
          application/json:
            schema: Operation
            example: |
              {
                "rt":             ["x.com.st.operationalstate.thermostat"],
                "id":             "unique_example_id",
                "currentJobState": "cooling",
                "jobStates" : ["cooling", "fan only", "heating", "idle", "pending cool", "pending heat", "vent economizer"],
                "currentMachineState": "stop",
                "machineStates" : ["stop", "pause", "run" ],
                "startingTime" : 1503374502,
                "endingTime" : 1503374528
              }

  post:
      description: |
        Sets the desired thermostat operational state
      body:
        application/json:
          schema: OperationUpdate
          example: |
            {
              "id":    "unique_example_id",
              "currentMachineState": "stop"
            }
      responses:
        200:
          body:
            application/json:
              schema: OperationUpdate
              example: |
                {
                  "id":    "unique_example_id",
                  "currentMachineState": "stop"
                }

        403:
          description: |
            This response is generated by the OIC Server when the client sends:
              An update with an value for currentcurrentMachineState that is not found in currentMachineStates.
            The server responds with the current resource representation.
          body:
            application/json:
              schema: OperationUpdate
              example: |
                {
                  "id": "unique_example_id",
                  "currentJobState": "cooling",
                  "jobStates" : ["cooling", "fan only", "heating", "idle", "pending cool", "pending heat", "vent economizer"],
                  "currentMachineState": "stop",
                  "machineStates" : ["stop", "pause", "run" ],
                  "startingTime" : 1503374502,
                  "endingTime" : 1503374528
                }
