This changes the custom code in UbiCli and the cli-commands files to use the Ruby SDK for all changes. This is slightly slower, but allows for testing Ruby SDK using the existing tests for the CLI. The only spec change is to an error message, and the error message is now more helpful. As the Ruby SDK uses symbol keys instead of string keys, this switches UbiCli and the cli-commands files to also use symbol keys. This adds an UbiCli#check_no_slash helper method to DRY up code that checks for slashes in strings used as path fragments.
21 lines
669 B
Ruby
21 lines
669 B
Ruby
# frozen_string_literal: true
|
|
|
|
UbiCli.on("pg").run_on("add-metric-destination") do
|
|
desc "Add a PostgreSQL metric destination"
|
|
|
|
banner "ubi pg (location/pg-name | pg-id) add-metric-destination username password url"
|
|
|
|
args 3
|
|
|
|
run do |username, password, url|
|
|
data = sdk_object.add_metric_destination(username:, password:, url:)
|
|
body = []
|
|
body << "Metric destination added to PostgreSQL database.\n"
|
|
body << "Current metric destinations:\n"
|
|
data[:metric_destinations].each_with_index do |md, i|
|
|
body << " " << (i + 1).to_s << ": " << md[:id] << " " << md[:username].to_s << " " << md[:url] << "\n"
|
|
end
|
|
response(body)
|
|
end
|
|
end
|