How to get REST switch state

Trying to follow your code, but am getting the following error:

Invalid config for [rest]: [switch] is an invalid option for [rest]. Check: rest->rest->1->switch. (See /config/configuration.yaml, line 45). 


and my code looks like this:

rest:
- resource: http://192.168.12.11/state.xml
    scan_interval: 32
    sensor:
      - name: Master Bedroom Chimney Fan
        value_template: "{{ value_json['datavalues']['relay1state'] }}"
     switch:
      - name: "Master Bedroom Chimney Fan"
        value_template: "{{ value_json['datavalues']['relay1state'] }}"
        turn_on:
          - service: rest_command.set_relay1state
            data:
              relay1state: 1
          - service: homeassistant.update_entity
            target:
              entity_id: sensor.master_bedroom_chimney_fan
          - delay: 00:00:15
          - service: homeassistant.update_entity
            target:
              entity_id: sensor.master_bedroom_chimney_fan
        turn_off:
          - service: rest_command.set_relay1state
            data:
              relay1state: 0
          - service: homeassistant.update_entity
            target:
              entity_id: sensor.master_bedroom_chimney_fan
          - delay: 00:00:15
          - service: homeassistant.update_entity
            target:
              entity_id: sensor.master_bedroom_chimney_fan

rest_command:
  set_relay1state:
    url: http://192.168.12.11/state.xml?relay1={{ relay1state }}

any ideas as to the error? I saw that you directly call CURL in the res_command, but I was trying to follow the API resources. Before I tried to integrate switch into restFul, the sensor portion was giving me the correct state of the relay so I know that part is fine.