mirror of
https://github.com/ubicloud/ubicloud.git
synced 2025-10-04 13:52:06 +08:00
This allows you to modify an existing firewall rule. You can modify the cidr and/or description for the rule. While implementing this, I noticed the api endpoint always required a cidr parameter, which made it more difficult to only modify the description. Additionally, if you provided a cidr without a description parameter, it would erase the current description, which seems unlikely to be the desired behavior. This makes both the cidr and description parameters optional, and if the parameter is not given, treat it the same as providing the current parameter value.
19 lines
780 B
Ruby
19 lines
780 B
Ruby
# frozen_string_literal: true
|
|
|
|
UbiCli.on("pg").run_on("modify-firewall-rule") do
|
|
desc "Modify a PostgreSQL firewall rule"
|
|
|
|
options("ubi pg (location/pg-name | pg-id) modify-firewall-rule [options] rule-id", key: :pg_fw_mod) do
|
|
on("-c", "--cidr=cidr", "ip range to allow in cidr format (e.g. 1.2.3.0/24)")
|
|
on("-d", "--description=desc", "description of rule")
|
|
end
|
|
|
|
args 1
|
|
|
|
run do |ubid, opts, cmd|
|
|
check_no_slash(ubid, "invalid firewall rule id format", cmd)
|
|
params = opts[:pg_fw_mod]
|
|
data = sdk_object.modify_firewall_rule(ubid, cidr: params[:cidr], description: params[:description])
|
|
response("PostgreSQL database firewall rule modified.\n rule id: #{data[:id]}\n cidr: #{data[:cidr]}\n description: #{data[:description].inspect}")
|
|
end
|
|
end
|