#%RAML 0.8
title: WWST Power Switch
version: v1.0.0-20170911
schemas:
- PowerSwitch: |
    {
      "id": "http://openinterconnect.org/iotdatamodels/schemas/x.com.st.powerswitch.json#",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "Copyright (c) 2016, 2017 Open Connectivity Foundation, Inc. All rights reserved.",
      "title": "Power",
      "definitions": {
        "x.com.st.powerswitch": {
          "type": "object",
          "properties": {
            "power": {
              "type": "string",
              "enum": [
                "on",
                "off"
              ],
              "description": "State of the power switch."
            }
          }
        }
      },
      "type": "object",
      "allOf": [
        {
          "$ref": "oic.baseResource.json#/definitions/oic.r.baseresource"
        },
        {
          "$ref": "#/definitions/x.com.st.powerswitch"
        }
      ],
      "required": [
        "power"
      ]
    }

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

/WWSTPowerSwitchResURI:
  description: |
        Turn on and off a device
  displayName: WWST Power Switch
  is: [ interface ]

  get:
    description: |
      Retrieves the state of the power switch.
    responses:
      200:
        body:
          application/json:
            schema: PowerSwitch
            example: |
              {
                "rt":         ["x.com.st.powerswitch"],
                "id":         "unique_example_id",
                "power":  "on"
              }

  post:
    description: |
      Sets the current power switch.
    body:
      application/json:
        schema: PowerSwitch
        example: |
          {
            "id":         "unique_example_id",
            "power":  "on"
          }
    responses:
      200:
        body:
          application/json:
            schema: PowerSwitch
            example: |
              {
                "id":         "unique_example_id",
                "power":  "on"
              }

      403:
        description: |
          This response is generated by the OIC Server when the client sends:
            An update with an invalid property value for power.
          The server responds with the current resource representation.
        body:
          application/json:
            schema: PowerSwitch
            example: |
              {
                "power": "on"
              }
