---
{%- from "syncthing/map.jinja" import syncthing with context %}
{%- set configdir=salt['user.info'](syncthing.user)['home'] + '/.config/syncthing' %}
#syncthing-config-dir:
#  file.directory:
#    - name: {{ configdir }}
#    - makedirs: true
  #    - watch_in:
  #      - service: syncthing-service

#syncthing-config-file:
#  file.managed:
#    - name: {{ configdir }}/config.xml
#    - source: salt://syncthing/config.xml.j2
#    - user: root
#    - group: root
#    - template: jinja
#    - watch_in:
#      - service: syncthing-service

{%- set config = salt['http.query'](url="http://localhost:8384/rest/system/config", header_dict={"X-API-Key":syncthing.apikey},decode=True, decode_type='json') %}
#{{ config['dict']['gui'] }}

{%- do salt['http.query'](method='POST', url="http://localhost:8384/rest/system/config", header_dict={"X-API-Key":syncthing.apikey}, decode=True, decode_type='json', data=json.dumps(syncthing.config)) %}