text: ---------------------------------------------------------------------------
  -- register a new device
  
  -- url: /api/iot/device_new
  
  -- input: namespace, name must be unique
  --  {
  --      "namespace:,
  --      "name":
  --      "type": "air|water"
  --      "config": { min_ph: }    -- see params
  --      "tags": ["foo.bar",...]
  --  }
  
  -- output:
  --  {
  --      "id"
  --      "namespace":
  --      "name":
  --      "config":
  --      "tags":
  --  }
  
  -- throws:
  --  error.unauthorized  -- admin rights required
  --  error.insufficient_params
  --  error.existing_device_found
  
  ---------------------------------------------------------------------------
  
  create function iot.web_device_new (req jsonb) returns jsonb as $$
  begin
      return to_jsonb(iot.device_new(iot.auth(req)));
  end;
  $$ language plpgsql security definer;
  
  