API call to update port alias

Started by Kieeps, Today at 02:20:12 PM

Previous topic - Next topic
so i have a alias for ports that are specific for a game server i have running, and whenever i set up a new game i just add a new alias, add the ports it needs and add that alias to the "main" gameserver alias.

i recently tried to automate this with the API but ran in to problems.

• # WORKS: clear AMP_PortGroup content
  curl -su "APIKEY:APISECRET" -X POST \
    -H 'Content-Type: application/json' \
    -d '{"alias":{"content":""}}' \
    "http://172.16.1.1:8899/api/firewall/alias/setItem/AMP_PORTGROUP_UUID"

  # WORKS: set AMP_PortGroup to ONE alias name
  curl -su "APIKEY:APISECRET" -X POST \
    -H 'Content-Type: application/json' \
    -d '{"alias":{"content":"ampt03_ports1"}}' \
    "http://172.16.1.1:8899/api/firewall/alias/setItem/AMP_PORTGROUP_UUID"

  # WORKS: create single-port alias
  curl -su "APIKEY:APISECRET" -X POST \
    -H 'Content-Type: application/json' \
    -d '{"alias":{"enabled":"1","name":"ampt03_ports1","type":"port","content":"33001"}}' \
    "http://172.16.1.1:8899/api/firewall/alias/addItem"

  # WORKS: apply changes
  curl -su "APIKEY:APISECRET" -X POST -d '' \
    "http://172.16.1.1:8899/api/firewall/alias/reconfigure"

  # DOES NOT WORK: create port alias with multiple ports (comma list)
  curl -su "APIKEY:APISECRET" -X POST \
    -H 'Content-Type: application/json' \
    -d '{"alias":{"enabled":"1","name":"ampt01_ports3","type":"port","content":"31001,31002,31003"}}' \
    "http://172.16.1.1:8899/api/firewall/alias/addItem"
  # => alias.content: Entry "... " is not a valid port number

  # DOES NOT WORK: set AMP_PortGroup with multiple alias names
  curl -su "APIKEY:APISECRET" -X POST \
    -H 'Content-Type: application/json' \
    -d '{"alias":{"content":"ampt01_ports3,ampt02_ports2,ampt03_ports1"}}' \
    "http://172.16.1.1:8899/api/firewall/alias/setItem/AMP_PORTGROUP_UUID"
  # => alias.content: Entry "... " is not a valid port number

  # DOES NOT WORK: alias_util add on port alias
  curl -su "APIKEY:APISECRET" -X POST -d '' \
    "http://172.16.1.1:8899/api/firewall/alias_util/add/AMP_PortGroup/ampt03_ports1"
  # => {"status":"failed"}

  # DOES NOT WORK: alias_util delete on port alias
  curl -su "APIKEY:APISECRET" -X POST -d '' \
    "http://172.16.1.1:8899/api/firewall/alias_util/delete/AMP_PortGroup/ampt03_ports1"
  # => {"status":"failed"}


So basically it seems like adding more then one "object" to an alias isn't working, or am i just formating it wrong?