Module: Aptible::CLI::Helpers::MetricDrain
- Includes:
- Token
- Defined in:
- lib/aptible/cli/helpers/metric_drain.rb
Constant Summary
Constants included
from Token
Token::TOKEN_ENV_VAR
Instance Method Summary
collapse
Methods included from Token
#current_token_hash, #fetch_token, #save_token, #token_file
Methods included from ConfigPath
#aptible_config_path
Instance Method Details
#create_metric_drain(account, drain_opts) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/aptible/cli/helpers/metric_drain.rb', line 7
def create_metric_drain(account, drain_opts)
drain = account.create_metric_drain!(drain_opts)
op = drain.create_operation(type: :provision)
if op.errors.any?
drain.create_operation(type: :deprovision)
raise Thor::Error, op.errors.full_messages.first
end
attach_to_operation_logs(op)
end
|
#ensure_metric_drain(account, handle) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/aptible/cli/helpers/metric_drain.rb', line 21
def ensure_metric_drain(account, handle)
drains = account.metric_drains.select { |d| d.handle == handle }
if drains.empty?
raise Thor::Error, "No drain found with handle #{handle}"
end
unless drains.length == 1
raise Thor::Error, "#{drains.length} drains found with handle "\
"#{handle}"
end
drains.first
end
|