zabbix_export:
  version: '6.0'
  date: '2023-03-03T18:03:28Z'
  groups:
    -
      uuid: 09e474428d704342a8dcadbf65e4efa3
      name: 'iiko API'
  hosts:
    -
      host: 'IIKO API Token Update'
      name: 'IIKO API Token Update'
      status: DISABLED
      groups:
        -
          name: 'iiko API'
      interfaces:
        -
          interface_ref: if1
      httptests:
        -
          name: 'Update iiko Auth Token'
          delay: 15m
          steps:
            -
              name: 'Get iiko API auth token'
              url: 'https://api-ru.iiko.services/api/1/access_token'
              posts: "{\r\n\"apiLogin\": \"{$IIKO_API_LOGIN}\"\r\n}"
              variables:
                -
                  name: '{iiko_api_token}'
                  value: 'regex: "token": "([^"]+)"'
              headers:
                -
                  name: Content-Type
                  value: application/json
              follow_redirects: 'NO'
              timeout: 3s
            -
              name: 'Zabbix API - Update Macros'
              url: '{$ZABBIX_API_URL}'
              posts: "{\r\n    \"jsonrpc\": \"2.0\",\r\n    \"method\": \"template.update\",\r\n    \"params\": {\r\n        \"templateid\": \"{$TEMPLATE_ID}\",\r\n        \"macros\": [\r\n            {\"macro\": \"{$TOKEN}\",\"value\": \"{iiko_api_token}\"},\r\n            {\"macro\": \"{$ID_ORG}\",\"value\": \"\"},\r\n            {\"macro\": \"{$ID_TERM1}\",\"value\": \"\"},\r\n            {\"macro\": \"{$ID_TERM2}\",\"value\": \"\"},\r\n            {\"macro\": \"{$ID_TERM3}\",\"value\": \"\"}\r\n        ]\r\n    },\r\n    \"id\": 1,\r\n    \"auth\": \"{$ZABBIX_API_TOKEN}\"\r\n}"
              headers:
                -
                  name: Content-Type
                  value: application/json-rpc
              follow_redirects: 'NO'
              timeout: 3s
      macros:
        -
          macro: '{$IIKO_API_LOGIN}'
          type: SECRET_TEXT
        -
          macro: '{$TEMPLATE_ID}'
        -
          macro: '{$ZABBIX_API_TOKEN}'
          type: SECRET_TEXT
        -
          macro: '{$ZABBIX_API_URL}'
          value: 'http://localhost/api_jsonrpc.php'
      inventory_mode: DISABLED
  triggers:
    -
      expression: 'last(/IIKO API Token Update/web.test.rspcode[Update iiko Auth Token,Get iiko API auth token])<>200'
      name: 'Не получен API Token IIKO'
      priority: WARNING
