#%RAML 0.8
title: WWST Dish Washer job state
version: v1.0.0-20170911
schemas:
- Operation: |
    {
      "id": "http://openinterconnect.org/iotdatamodels/schemas/x.com.st.operationalstate.dishwasher.json#",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "Copyright (c) 2016, 2017 Open Connectivity Foundation, Inc. All rights reserved.",
      "title": "Operation",
      "definitions": {
        "x.com.st.operationalstate.dishwasher": {
          "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.dishwasher"
        }
      ],
      "required": [
        "jobStates","currentJobState","machineStates","currentMachineState"
      ]
    }

- OperationUpdate: |
    {
      "id": "http://openinterconnect.org/iotdatamodels/schemas/x.com.st.operationalstate.dishwasher.json#",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "Copyright (c) 2016, 2017 Open Connectivity Foundation, Inc. All rights reserved.",
      "title": "Operational State",
      "definitions": {
        "x.com.st.operationalstate.dishwasher": {
          "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.dishwasher"
        }
      ],
      "required": [
        "currentMachineState"
      ]
    }

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

/WWSTDishWasherjobstateResURI:
  description: |
        Dish Washer job state
  displayName: WWST Dish Washer job state
  is: [ interface ]

  get:
    description: |
      Retrieves the current Dish Washer job state
    responses:
      200:
        body:
          application/json:
            schema: Operation
            example: |
              {
                "rt": ["x.com.st.operationalstate.dishwasher"],
                "id": "unique_example_id",
                "currentJobState": "cooling",
                "jobStates" : ["cooling","drying","finish","preDrain","prewash","rinse","spin","unknown","wash"],
                "currentMachineState": "stop",
                "machineStates" : ["stop", "pause", "run" ],
                "startingTime" : 1503374502,
                "endingTime" : 1503374528
              }

  post:
    description: |
      Sets the desired operational or job 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.
            An update with an value for currentJobState that is not found in jobStates.
          The server responds with the current resource representation.
        body:
          application/json:
            schema: Operation
            example: |
              {
                "id": "unique_example_id",
                "currentJobState": "cooling",
                "jobStates" : ["cooling","drying","finish","preDrain","prewash","rinse","spin","unknown","wash"],
                "currentMachineState": "stop",
                "machineStates" : ["stop", "pause", "run" ],
                "startingTime" : 1503374502,
                "endingTime" : 1503374528
              }
