aptible-cli 0.18.1 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +64 -50
- data/lib/aptible/cli/agent.rb +9 -3
- data/lib/aptible/cli/helpers/config_path.rb +11 -0
- data/lib/aptible/cli/helpers/log_drain.rb +85 -0
- data/lib/aptible/cli/helpers/metric_drain.rb +39 -0
- data/lib/aptible/cli/helpers/ssh.rb +5 -1
- data/lib/aptible/cli/helpers/token.rb +5 -1
- data/lib/aptible/cli/helpers/vhost/option_set_builder.rb +17 -6
- data/lib/aptible/cli/resource_formatter.rb +61 -3
- data/lib/aptible/cli/subcommands/apps.rb +5 -40
- data/lib/aptible/cli/subcommands/backup.rb +15 -7
- data/lib/aptible/cli/subcommands/db.rb +24 -21
- data/lib/aptible/cli/subcommands/endpoints.rb +16 -0
- data/lib/aptible/cli/subcommands/log_drain.rb +159 -0
- data/lib/aptible/cli/subcommands/metric_drain.rb +141 -0
- data/lib/aptible/cli/version.rb +1 -1
- data/spec/aptible/cli/subcommands/apps_spec.rb +0 -47
- data/spec/aptible/cli/subcommands/backup_spec.rb +1 -1
- data/spec/aptible/cli/subcommands/db_spec.rb +0 -26
- data/spec/aptible/cli/subcommands/endpoints_spec.rb +39 -0
- data/spec/aptible/cli/subcommands/log_drain_spec.rb +207 -0
- data/spec/aptible/cli/subcommands/metric_drain_spec.rb +183 -0
- data/spec/fabricators/account_fabricator.rb +2 -0
- data/spec/fabricators/database_disk_fabricator.rb +2 -1
- data/spec/fabricators/log_drain_fabricator.rb +21 -0
- data/spec/fabricators/metric_drain_fabricator.rb +8 -0
- metadata +15 -5
- data/lib/aptible/cli/subcommands/domains.rb +0 -40
- data/spec/aptible/cli/subcommands/domains_spec.rb +0 -76
@@ -52,52 +52,17 @@ module Aptible
|
|
52
52
|
app_options
|
53
53
|
option :container_count, type: :numeric
|
54
54
|
option :container_size, type: :numeric
|
55
|
-
|
56
|
-
desc: 'DEPRECATED, use --container-size'
|
57
|
-
define_method 'apps:scale' do |type, *more|
|
55
|
+
define_method 'apps:scale' do |type|
|
58
56
|
service = ensure_service(options, type)
|
59
57
|
|
60
58
|
container_count = options[:container_count]
|
61
59
|
container_size = options[:container_size]
|
62
60
|
|
63
|
-
# There are two legacy options we have to process here:
|
64
|
-
# - We used to accept apps:scale SERVICE COUNT
|
65
|
-
# - We used to accept --size
|
66
|
-
case more.size
|
67
|
-
when 0
|
68
|
-
# Noop
|
69
|
-
when 1
|
70
|
-
if container_count.nil?
|
71
|
-
m = 'Passing container count as a positional ' \
|
72
|
-
'argument is deprecated, use --container-count'
|
73
|
-
CLI.logger.warn(m)
|
74
|
-
container_count = Integer(more.first)
|
75
|
-
else
|
76
|
-
raise Thor::Error, 'Container count was passed via both ' \
|
77
|
-
'the --container-count keyword argument ' \
|
78
|
-
'and a positional argument. ' \
|
79
|
-
'Use only --container-count to proceed.'
|
80
|
-
end
|
81
|
-
else
|
82
|
-
# Unfortunately, Thor does not want to let us easily hook into
|
83
|
-
# its usage formatting, so we have to work around it here.
|
84
|
-
command = thor.commands.fetch('apps:scale')
|
85
|
-
error = ArgumentError.new
|
86
|
-
args = [type] + more
|
87
|
-
thor.handle_argument_error(command, error, args, 1)
|
88
|
-
end
|
89
|
-
|
90
61
|
if options[:size]
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
container_size = options[:size]
|
96
|
-
else
|
97
|
-
raise Thor::Error, 'Container size was passed via both ' \
|
98
|
-
'--container-size and --size. ' \
|
99
|
-
'Use only --container-size to proceed.'
|
100
|
-
end
|
62
|
+
m = 'You have used the "--size" option to specify a container '\
|
63
|
+
'size. This abiguous option has been removed.'\
|
64
|
+
'Please use the "--container-size" option, instead.'
|
65
|
+
raise Thor::Error, m
|
101
66
|
end
|
102
67
|
|
103
68
|
if container_count.nil? && container_size.nil?
|
@@ -39,16 +39,17 @@ module Aptible
|
|
39
39
|
type: 'restore',
|
40
40
|
handle: handle,
|
41
41
|
container_size: options[:container_size],
|
42
|
-
disk_size: options[:disk_size]
|
42
|
+
disk_size: options[:disk_size],
|
43
43
|
destination_account: destination_account,
|
44
44
|
key_arn: options[:key_arn]
|
45
45
|
}.delete_if { |_, v| v.nil? }
|
46
46
|
|
47
|
-
|
48
|
-
'You have used the "--size" option to specify a disk size.'
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
if options[:size]
|
48
|
+
m = 'You have used the "--size" option to specify a disk size.'\
|
49
|
+
'This abiguous option has been removed.'\
|
50
|
+
'Please use the "--disk-size" option, instead.'
|
51
|
+
raise Thor::Error, m
|
52
|
+
end
|
52
53
|
|
53
54
|
operation = backup.create_operation!(opts)
|
54
55
|
CLI.logger.info "Restoring backup into #{handle}"
|
@@ -123,7 +124,14 @@ module Aptible
|
|
123
124
|
|
124
125
|
operation = backup.create_operation!(type: 'purge')
|
125
126
|
CLI.logger.info "Purging backup #{backup_id}"
|
126
|
-
|
127
|
+
begin
|
128
|
+
attach_to_operation_logs(operation)
|
129
|
+
rescue HyperResource::ClientError => e
|
130
|
+
# A 404 here means that the operation completed successfully,
|
131
|
+
# and was removed faster than attach_to_operation_logs
|
132
|
+
# could attach to the logs.
|
133
|
+
raise if e.response.status != 404
|
134
|
+
end
|
127
135
|
end
|
128
136
|
end
|
129
137
|
end
|
@@ -59,8 +59,8 @@ module Aptible
|
|
59
59
|
option :type, type: :string
|
60
60
|
option :version, type: :string
|
61
61
|
option :container_size, type: :numeric
|
62
|
-
option :size, type: :numeric
|
63
62
|
option :disk_size, default: 10, type: :numeric
|
63
|
+
option :size, type: :numeric
|
64
64
|
option :key_arn, type: :string
|
65
65
|
option :environment
|
66
66
|
define_method 'db:create' do |handle|
|
@@ -69,15 +69,16 @@ module Aptible
|
|
69
69
|
db_opts = {
|
70
70
|
handle: handle,
|
71
71
|
initial_container_size: options[:container_size],
|
72
|
-
initial_disk_size: options[:disk_size]
|
72
|
+
initial_disk_size: options[:disk_size],
|
73
73
|
current_kms_arn: options[:key_arn]
|
74
74
|
}.delete_if { |_, v| v.nil? }
|
75
75
|
|
76
|
-
|
77
|
-
'You have used the "--size" option to specify a disk size.'
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
if options[:size]
|
77
|
+
m = 'You have used the "--size" option to specify a disk size.'\
|
78
|
+
'This abiguous option has been removed.'\
|
79
|
+
'Please use the "--disk-size" option, instead.'
|
80
|
+
raise Thor::Error, m
|
81
|
+
end
|
81
82
|
|
82
83
|
type = options[:type]
|
83
84
|
version = options[:version]
|
@@ -97,7 +98,7 @@ module Aptible
|
|
97
98
|
op_opts = {
|
98
99
|
type: 'provision',
|
99
100
|
container_size: options[:container_size],
|
100
|
-
disk_size: options[:disk_size]
|
101
|
+
disk_size: options[:disk_size]
|
101
102
|
}.delete_if { |_, v| v.nil? }
|
102
103
|
op = database.create_operation(op_opts)
|
103
104
|
|
@@ -156,17 +157,18 @@ module Aptible
|
|
156
157
|
opts = {
|
157
158
|
environment: options[:environment],
|
158
159
|
container_size: options[:container_size],
|
159
|
-
size: options[:disk_size]
|
160
|
+
size: options[:disk_size],
|
160
161
|
logical: options[:logical],
|
161
162
|
database_image: image || nil,
|
162
163
|
key_arn: options[:key_arn]
|
163
164
|
}.delete_if { |_, v| v.nil? }
|
164
165
|
|
165
|
-
|
166
|
-
'You have used the "--size" option to specify a disk size.'
|
167
|
-
|
168
|
-
|
169
|
-
|
166
|
+
if options[:size]
|
167
|
+
m = 'You have used the "--size" option to specify a disk size.'\
|
168
|
+
'This abiguous option has been removed.'\
|
169
|
+
'Please use the "--disk-size" option, instead.'
|
170
|
+
raise Thor::Error, m
|
171
|
+
end
|
170
172
|
|
171
173
|
database = replicate_database(source, dest_handle, opts)
|
172
174
|
render_database(database.reload, database.account)
|
@@ -279,7 +281,7 @@ module Aptible
|
|
279
281
|
end
|
280
282
|
|
281
283
|
desc 'db:restart HANDLE ' \
|
282
|
-
'[--container-size SIZE_MB] [--disk-size SIZE_GB]' \
|
284
|
+
'[--container-size SIZE_MB] [--disk-size SIZE_GB] ' \
|
283
285
|
'[--iops IOPS] [--volume-type [gp2, gp3]]',
|
284
286
|
'Restart a database'
|
285
287
|
option :environment
|
@@ -294,16 +296,17 @@ module Aptible
|
|
294
296
|
opts = {
|
295
297
|
type: 'restart',
|
296
298
|
container_size: options[:container_size],
|
297
|
-
disk_size: options[:disk_size]
|
299
|
+
disk_size: options[:disk_size],
|
298
300
|
provisioned_iops: options[:iops],
|
299
301
|
ebs_volume_type: options[:volume_type]
|
300
302
|
}.delete_if { |_, v| v.nil? }
|
301
303
|
|
302
|
-
|
303
|
-
'You have used the "--size" option to specify a disk size.'
|
304
|
-
|
305
|
-
|
306
|
-
|
304
|
+
if options[:size]
|
305
|
+
m = 'You have used the "--size" option to specify a disk size.'\
|
306
|
+
'This abiguous option has been removed.'\
|
307
|
+
'Please use the "--disk-size" option, instead.'
|
308
|
+
raise Thor::Error, m
|
309
|
+
end
|
307
310
|
|
308
311
|
CLI.logger.info "Restarting #{database.handle}..."
|
309
312
|
op = database.create_operation!(opts)
|
@@ -33,6 +33,22 @@ module Aptible
|
|
33
33
|
provision_vhost_and_explain(service, vhost)
|
34
34
|
end
|
35
35
|
|
36
|
+
database_modify_flags = Helpers::Vhost::OptionSetBuilder.new do
|
37
|
+
database!
|
38
|
+
end
|
39
|
+
|
40
|
+
desc 'endpoints:database:modify --database DATABASE ' \
|
41
|
+
'ENDPOINT_HOSTNAME',
|
42
|
+
'Modify a Database Endpoint'
|
43
|
+
database_modify_flags.declare_options(self)
|
44
|
+
define_method 'endpoints:database:modify' do |hostname|
|
45
|
+
database = ensure_database(options.merge(db: options[:database]))
|
46
|
+
vhost = find_vhost(each_service(database), hostname)
|
47
|
+
vhost.update!(**database_modify_flags.prepare(database.account,
|
48
|
+
options))
|
49
|
+
provision_vhost_and_explain(vhost.service, vhost)
|
50
|
+
end
|
51
|
+
|
36
52
|
tcp_create_flags = Helpers::Vhost::OptionSetBuilder.new do
|
37
53
|
app!
|
38
54
|
create!
|
@@ -0,0 +1,159 @@
|
|
1
|
+
module Aptible
|
2
|
+
module CLI
|
3
|
+
module Subcommands
|
4
|
+
module LogDrain
|
5
|
+
def self.included(thor)
|
6
|
+
thor.class_eval do
|
7
|
+
include Helpers::Token
|
8
|
+
include Helpers::Database
|
9
|
+
include Helpers::LogDrain
|
10
|
+
|
11
|
+
drain_flags = '--environment ENVIRONMENT ' \
|
12
|
+
'[--drain-apps true/false] ' \
|
13
|
+
'[--drain_databases true/false] ' \
|
14
|
+
'[--drain_ephemeral_sessions true/false] ' \
|
15
|
+
'[--drain_proxies true/false]'
|
16
|
+
|
17
|
+
def self.drain_options
|
18
|
+
option :drain_apps, default: true, type: :boolean
|
19
|
+
option :drain_databases, default: true, type: :boolean
|
20
|
+
option :drain_ephemeral_sessions, default: true, type: :boolean
|
21
|
+
option :drain_proxies, default: true, type: :boolean
|
22
|
+
option :environment
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'log_drain:list', 'List all Log Drains'
|
26
|
+
option :environment
|
27
|
+
define_method 'log_drain:list' do
|
28
|
+
Formatter.render(Renderer.current) do |root|
|
29
|
+
root.grouped_keyed_list(
|
30
|
+
{ 'environment' => 'handle' },
|
31
|
+
'handle'
|
32
|
+
) do |node|
|
33
|
+
scoped_environments(options).each do |account|
|
34
|
+
account.log_drains.each do |drain|
|
35
|
+
node.object do |n|
|
36
|
+
ResourceFormatter.inject_log_drain(n, drain, account)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'log_drain:create:elasticsearch HANDLE '\
|
45
|
+
'--db DATABASE_HANDLE ' \
|
46
|
+
+ drain_flags,
|
47
|
+
'Create an Elasticsearch Log Drain'
|
48
|
+
drain_options
|
49
|
+
option :db, type: :string
|
50
|
+
option :pipeline, type: :string
|
51
|
+
define_method 'log_drain:create:elasticsearch' do |handle|
|
52
|
+
account = ensure_environment(options)
|
53
|
+
database = ensure_database(options)
|
54
|
+
|
55
|
+
opts = {
|
56
|
+
handle: handle,
|
57
|
+
database_id: database.id,
|
58
|
+
logging_token: options[:pipeline],
|
59
|
+
drain_apps: options[:drain_apps],
|
60
|
+
drain_databases: options[:drain_databases],
|
61
|
+
drain_ephemeral_sessions: options[:drain_ephemeral_sessions],
|
62
|
+
drain_proxies: options[:drain_proxies],
|
63
|
+
drain_type: :elasticsearch_database
|
64
|
+
}
|
65
|
+
|
66
|
+
create_log_drain(account, opts)
|
67
|
+
end
|
68
|
+
|
69
|
+
desc 'log_drain:create:datadog HANDLE ' \
|
70
|
+
'--url DATADOG_URL ' \
|
71
|
+
+ drain_flags,
|
72
|
+
'Create a Datadog Log Drain'
|
73
|
+
drain_options
|
74
|
+
option :url, type: :string
|
75
|
+
define_method 'log_drain:create:datadog' do |handle|
|
76
|
+
msg = 'Must be in the format of ' \
|
77
|
+
'"https://http-intake.logs.datadoghq.com' \
|
78
|
+
'/v1/input/<DD_API_KEY>".'
|
79
|
+
create_https_based_log_drain(handle, options, url_format_msg: msg)
|
80
|
+
end
|
81
|
+
|
82
|
+
desc 'log_drain:create:https HANDLE ' \
|
83
|
+
'--url URL ' \
|
84
|
+
+ drain_flags,
|
85
|
+
'Create a HTTPS Drain'
|
86
|
+
option :url, type: :string
|
87
|
+
drain_options
|
88
|
+
define_method 'log_drain:create:https' do |handle|
|
89
|
+
create_https_based_log_drain(handle, options)
|
90
|
+
end
|
91
|
+
|
92
|
+
desc 'log_drain:create:sumologic HANDLE ' \
|
93
|
+
'--url SUMOLOGIC_URL ' \
|
94
|
+
+ drain_flags,
|
95
|
+
'Create a Sumologic Drain'
|
96
|
+
option :url, type: :string
|
97
|
+
drain_options
|
98
|
+
define_method 'log_drain:create:sumologic' do |handle|
|
99
|
+
create_https_based_log_drain(handle, options)
|
100
|
+
end
|
101
|
+
|
102
|
+
desc 'log_drain:create:logdna HANDLE ' \
|
103
|
+
'--url LOGDNA_URL ' \
|
104
|
+
+ drain_flags,
|
105
|
+
'Create a LogDNA Log Drain'
|
106
|
+
option :url, type: :string
|
107
|
+
drain_options
|
108
|
+
define_method 'log_drain:create:logdna' do |handle|
|
109
|
+
msg = 'Must be in the format of ' \
|
110
|
+
'"https://logs.logdna.com/aptible/ingest/<INGESTION KEY>".'
|
111
|
+
create_https_based_log_drain(handle, options, url_format_msg: msg)
|
112
|
+
end
|
113
|
+
|
114
|
+
desc 'log_drain:create:papertrail HANDLE ' \
|
115
|
+
'--host PAPERTRAIL_HOST --port PAPERTRAIL_PORT ' \
|
116
|
+
+ drain_flags,
|
117
|
+
'Create a Papertrail Log Drain'
|
118
|
+
option :host, type: :string
|
119
|
+
option :port, type: :string
|
120
|
+
drain_options
|
121
|
+
define_method 'log_drain:create:papertrail' do |handle|
|
122
|
+
create_syslog_based_log_drain(handle, options)
|
123
|
+
end
|
124
|
+
|
125
|
+
desc 'log_drain:create:syslog HANDLE ' \
|
126
|
+
'--host SYSLOG_HOST --port SYSLOG_PORT ' \
|
127
|
+
'[--token TOKEN] ' \
|
128
|
+
+ drain_flags,
|
129
|
+
'Create a Papertrail Log Drain'
|
130
|
+
option :host, type: :string
|
131
|
+
option :port, type: :string
|
132
|
+
option :token, type: :string
|
133
|
+
drain_options
|
134
|
+
define_method 'log_drain:create:syslog' do |handle|
|
135
|
+
create_syslog_based_log_drain(handle, options)
|
136
|
+
end
|
137
|
+
|
138
|
+
desc 'log_drain:deprovision HANDLE --environment ENVIRONMENT',
|
139
|
+
'Deprovisions a log drain'
|
140
|
+
option :environment
|
141
|
+
define_method 'log_drain:deprovision' do |handle|
|
142
|
+
account = ensure_environment(options)
|
143
|
+
drain = ensure_log_drain(account, handle)
|
144
|
+
op = drain.create_operation(type: :deprovision)
|
145
|
+
begin
|
146
|
+
attach_to_operation_logs(op)
|
147
|
+
rescue HyperResource::ClientError => e
|
148
|
+
# A 404 here means that the operation completed successfully,
|
149
|
+
# and was removed faster than attach_to_operation_logs
|
150
|
+
# could attach to the logs.
|
151
|
+
raise if e.response.status != 404
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module Aptible
|
2
|
+
module CLI
|
3
|
+
module Subcommands
|
4
|
+
module MetricDrain
|
5
|
+
SITES = {
|
6
|
+
'US1' => 'https://app.datadoghq.com',
|
7
|
+
'US3' => 'https://us3.datadoghq.com',
|
8
|
+
'EU1' => 'https://app.datadoghq.eu',
|
9
|
+
'US1-FED' => 'https://app.ddog-gov.com'
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
def self.included(thor)
|
13
|
+
thor.class_eval do
|
14
|
+
include Helpers::Token
|
15
|
+
include Helpers::Database
|
16
|
+
include Helpers::MetricDrain
|
17
|
+
|
18
|
+
desc 'metric_drain:list', 'List all Metric Drains'
|
19
|
+
option :environment
|
20
|
+
define_method 'metric_drain:list' do
|
21
|
+
Formatter.render(Renderer.current) do |root|
|
22
|
+
root.grouped_keyed_list(
|
23
|
+
{ 'environment' => 'handle' },
|
24
|
+
'handle'
|
25
|
+
) do |node|
|
26
|
+
scoped_environments(options).each do |account|
|
27
|
+
account.metric_drains.each do |drain|
|
28
|
+
node.object do |n|
|
29
|
+
ResourceFormatter.inject_metric_drain(n, drain, account)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'metric_drain:create:influxdb HANDLE '\
|
38
|
+
'--db DATABASE_HANDLE --environment ENVIRONMENT',
|
39
|
+
'Create an InfluxDB Metric Drain'
|
40
|
+
option :db, type: :string
|
41
|
+
option :environment
|
42
|
+
|
43
|
+
define_method 'metric_drain:create:influxdb' do |handle|
|
44
|
+
account = ensure_environment(options)
|
45
|
+
database = ensure_database(options)
|
46
|
+
|
47
|
+
opts = {
|
48
|
+
handle: handle,
|
49
|
+
database_id: database.id,
|
50
|
+
drain_type: :influxdb_database
|
51
|
+
}
|
52
|
+
|
53
|
+
create_metric_drain(account, opts)
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'metric_drain:create:influxdb:custom HANDLE '\
|
57
|
+
'--username USERNAME --password PASSWORD ' \
|
58
|
+
'--url URL_INCLUDING_PORT ' \
|
59
|
+
'--db INFLUX_DATABASE_NAME ' \
|
60
|
+
'--environment ENVIRONMENT',
|
61
|
+
'Create an InfluxDB Metric Drain'
|
62
|
+
option :db, type: :string
|
63
|
+
option :username, type: :string
|
64
|
+
option :password, type: :string
|
65
|
+
option :url, type: :string
|
66
|
+
option :db, type: :string
|
67
|
+
option :environment
|
68
|
+
define_method 'metric_drain:create:influxdb:custom' do |handle|
|
69
|
+
account = ensure_environment(options)
|
70
|
+
|
71
|
+
config = {
|
72
|
+
address: options[:url],
|
73
|
+
username: options[:username],
|
74
|
+
password: options[:password],
|
75
|
+
database: options[:db]
|
76
|
+
}
|
77
|
+
opts = {
|
78
|
+
handle: handle,
|
79
|
+
drain_configuration: config,
|
80
|
+
drain_type: :influxdb
|
81
|
+
}
|
82
|
+
|
83
|
+
create_metric_drain(account, opts)
|
84
|
+
end
|
85
|
+
|
86
|
+
desc 'metric_drain:create:datadog HANDLE '\
|
87
|
+
'--api_key DATADOG_API_KEY '\
|
88
|
+
'--site DATADOG_SITE ' \
|
89
|
+
'--environment ENVIRONMENT',
|
90
|
+
'Create a Datadog Metric Drain'
|
91
|
+
option :api_key, type: :string
|
92
|
+
option :site, type: :string
|
93
|
+
option :environment
|
94
|
+
define_method 'metric_drain:create:datadog' do |handle|
|
95
|
+
account = ensure_environment(options)
|
96
|
+
|
97
|
+
config = {
|
98
|
+
api_key: options[:api_key]
|
99
|
+
}
|
100
|
+
unless options[:site].nil?
|
101
|
+
site = SITES[options[:site]]
|
102
|
+
|
103
|
+
unless site
|
104
|
+
sites = SITES.keys.join(', ')
|
105
|
+
raise Thor::Error, 'Invalid Datadog site. ' \
|
106
|
+
"Valid options are #{sites}"
|
107
|
+
end
|
108
|
+
|
109
|
+
config[:series_url] = site
|
110
|
+
end
|
111
|
+
opts = {
|
112
|
+
handle: handle,
|
113
|
+
drain_type: :datadog,
|
114
|
+
drain_configuration: config
|
115
|
+
}
|
116
|
+
|
117
|
+
create_metric_drain(account, opts)
|
118
|
+
end
|
119
|
+
|
120
|
+
desc 'metric_drain:deprovision HANDLE --environment ENVIRONMENT',
|
121
|
+
'Deprovisions a Metric Drain'
|
122
|
+
option :environment
|
123
|
+
define_method 'metric_drain:deprovision' do |handle|
|
124
|
+
account = ensure_environment(options)
|
125
|
+
drain = ensure_metric_drain(account, handle)
|
126
|
+
op = drain.create_operation(type: :deprovision)
|
127
|
+
begin
|
128
|
+
attach_to_operation_logs(op)
|
129
|
+
rescue HyperResource::ClientError => e
|
130
|
+
# A 404 here means that the operation completed successfully,
|
131
|
+
# and was removed faster than attach_to_operation_logs
|
132
|
+
# could attach to the logs.
|
133
|
+
raise if e.response.status != 404
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|