aptible-cli 0.18.3 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99e721103b6988c5c8e41d11935449de499b29db00513732c031098f29613f29
4
- data.tar.gz: 19b4bc6ce3b14b759ef100eab8ca95f12809bb0fd41e5c36b709dfd224ab774b
3
+ metadata.gz: ee325f4c1746513670e64830cd10d8856fc39cc96e836c8f822e4c34ed6c45ea
4
+ data.tar.gz: 0dab373981390ea9d3429a6f0f43634eef13285bd090542329866bb1ff24620c
5
5
  SHA512:
6
- metadata.gz: 7c5e417a9ab05f619e140ff6c444bdd9723aa6d9b5063678201e018873a8065f245074ba872fc0fd00763a54e9f7c156e67762118bdcb156893f8a9668aab8b6
7
- data.tar.gz: 9355ca55bb61608245dfd0c8a1a7463ac555ab365cf389f12bec78b293861ab43f8776aef2c3c5fe8f0a0b42e3730f59ea3025d03c84ffc46d048c7b6933e90c
6
+ metadata.gz: 27fb8c12ceb02f977f29777bd418a2aa943c754d6b8cdc6a37ee55995bbe4a45dea9683c7191b4529017484b37dd3ef6dfcd3f2d70d2010ea032a0d1199409fd
7
+ data.tar.gz: b30888eb2d2855b388d04013eca773f4e69f77734c92aeee442499e7a266708c5a85800e0552ad0e739a40d1beb41956babcc4a2b9a0483d12be86939ac95c32
data/README.md CHANGED
@@ -28,56 +28,69 @@ From `aptible help`:
28
28
  <!-- BEGIN USAGE -->
29
29
  ```
30
30
  Commands:
31
- aptible apps # List all applications
32
- aptible apps:create HANDLE # Create a new application
33
- aptible apps:deprovision # Deprovision an app
34
- aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] # Scale a service
35
- aptible backup:list DB_HANDLE # List backups for a database
36
- aptible backup:orphaned # List backups associated with deprovisioned databases
37
- aptible backup:purge BACKUP_ID # Permanently delete a backup and any copies of it
38
- aptible backup:restore BACKUP_ID [--environment ENVIRONMENT_HANDLE] [--handle HANDLE] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--key-arn KEY_ARN] # Restore a backup
39
- aptible config # Print an app's current configuration
40
- aptible config:add [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
41
- aptible config:rm [VAR1] [VAR2] [...] # Remove an ENV variable from an app
42
- aptible config:set [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
43
- aptible config:unset [VAR1] [VAR2] [...] # Remove an ENV variable from an app
44
- aptible db:backup HANDLE # Backup a database
45
- aptible db:clone SOURCE DEST # Clone a database to create a new one
46
- aptible db:create HANDLE [--type TYPE] [--version VERSION] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--key-arn KEY_ARN] # Create a new database
47
- aptible db:deprovision HANDLE # Deprovision a database
48
- aptible db:dump HANDLE [pg_dump options] # Dump a remote database to file
49
- aptible db:execute HANDLE SQL_FILE [--on-error-stop] # Executes sql against a database
50
- aptible db:list # List all databases
51
- aptible db:modify HANDLE [--iops IOPS] [--volume-type [gp2, gp3]] # Modify a database disk
52
- aptible db:reload HANDLE # Reload a database
53
- aptible db:replicate HANDLE REPLICA_HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--logical --version VERSION] [--key-arn KEY_ARN] # Create a replica/follower of a database
54
- aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--iops IOPS] [--volume-type [gp2, gp3]] # Restart a database
55
- aptible db:tunnel HANDLE # Create a local tunnel to a database
56
- aptible db:url HANDLE # Display a database URL
57
- aptible db:versions # List available database versions
58
- aptible deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...] # Deploy an app
59
- aptible domains # Print an app's current virtual domains - DEPRECATED
60
- aptible endpoints:database:create DATABASE # Create a Database Endpoint
61
- aptible endpoints:deprovision [--app APP | --database DATABASE] ENDPOINT_HOSTNAME # Deprovision an App or Database Endpoint
62
- aptible endpoints:https:create [--app APP] SERVICE # Create an App HTTPS Endpoint
63
- aptible endpoints:https:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App HTTPS Endpoint
64
- aptible endpoints:list [--app APP | --database DATABASE] # List Endpoints for an App or Database
65
- aptible endpoints:renew [--app APP] ENDPOINT_HOSTNAME # Renew an App Managed TLS Endpoint
66
- aptible endpoints:tcp:create [--app APP] SERVICE # Create an App TCP Endpoint
67
- aptible endpoints:tcp:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TCP Endpoint
68
- aptible endpoints:tls:create [--app APP] SERVICE # Create an App TLS Endpoint
69
- aptible endpoints:tls:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TLS Endpoint
70
- aptible environment:ca_cert # Retrieve the CA certificate associated with the environment
71
- aptible environment:list # List all environments
72
- aptible help [COMMAND] # Describe available commands or one specific command
73
- aptible login # Log in to Aptible
74
- aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
75
- aptible operation:cancel OPERATION_ID # Cancel a running operation
76
- aptible rebuild # Rebuild an app, and restart its services
77
- aptible restart # Restart all services associated with an app
78
- aptible services # List Services for an App
79
- aptible ssh [COMMAND] # Run a command against an app
80
- aptible version # Print Aptible CLI version
31
+ aptible apps # List all applications
32
+ aptible apps:create HANDLE # Create a new application
33
+ aptible apps:deprovision # Deprovision an app
34
+ aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] # Scale a service
35
+ aptible backup:list DB_HANDLE # List backups for a database
36
+ aptible backup:orphaned # List backups associated with deprovisioned databases
37
+ aptible backup:purge BACKUP_ID # Permanently delete a backup and any copies of it
38
+ aptible backup:restore BACKUP_ID [--environment ENVIRONMENT_HANDLE] [--handle HANDLE] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--key-arn KEY_ARN] # Restore a backup
39
+ aptible config # Print an app's current configuration
40
+ aptible config:add [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
41
+ aptible config:rm [VAR1] [VAR2] [...] # Remove an ENV variable from an app
42
+ aptible config:set [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
43
+ aptible config:unset [VAR1] [VAR2] [...] # Remove an ENV variable from an app
44
+ aptible db:backup HANDLE # Backup a database
45
+ aptible db:clone SOURCE DEST # Clone a database to create a new one
46
+ aptible db:create HANDLE [--type TYPE] [--version VERSION] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--key-arn KEY_ARN] # Create a new database
47
+ aptible db:deprovision HANDLE # Deprovision a database
48
+ aptible db:dump HANDLE [pg_dump options] # Dump a remote database to file
49
+ aptible db:execute HANDLE SQL_FILE [--on-error-stop] # Executes sql against a database
50
+ aptible db:list # List all databases
51
+ aptible db:modify HANDLE [--iops IOPS] [--volume-type [gp2, gp3]] # Modify a database disk
52
+ aptible db:reload HANDLE # Reload a database
53
+ aptible db:replicate HANDLE REPLICA_HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--logical --version VERSION] [--key-arn KEY_ARN] # Create a replica/follower of a database
54
+ aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--iops IOPS] [--volume-type [gp2, gp3]] # Restart a database
55
+ aptible db:tunnel HANDLE # Create a local tunnel to a database
56
+ aptible db:url HANDLE # Display a database URL
57
+ aptible db:versions # List available database versions
58
+ aptible deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...] # Deploy an app
59
+ aptible endpoints:database:create DATABASE # Create a Database Endpoint
60
+ aptible endpoints:deprovision [--app APP | --database DATABASE] ENDPOINT_HOSTNAME # Deprovision an App or Database Endpoint
61
+ aptible endpoints:https:create [--app APP] SERVICE # Create an App HTTPS Endpoint
62
+ aptible endpoints:https:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App HTTPS Endpoint
63
+ aptible endpoints:list [--app APP | --database DATABASE] # List Endpoints for an App or Database
64
+ aptible endpoints:renew [--app APP] ENDPOINT_HOSTNAME # Renew an App Managed TLS Endpoint
65
+ aptible endpoints:tcp:create [--app APP] SERVICE # Create an App TCP Endpoint
66
+ aptible endpoints:tcp:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TCP Endpoint
67
+ aptible endpoints:tls:create [--app APP] SERVICE # Create an App TLS Endpoint
68
+ aptible endpoints:tls:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TLS Endpoint
69
+ aptible environment:ca_cert # Retrieve the CA certificate associated with the environment
70
+ aptible environment:list # List all environments
71
+ aptible help [COMMAND] # Describe available commands or one specific command
72
+ aptible log_drain:create:datadog HANDLE --url DATADOG_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Datadog Log Drain
73
+ aptible log_drain:create:elasticsearch HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create an Elasticsearch Log Drain
74
+ aptible log_drain:create:https HANDLE --url URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a HTTPS Drain
75
+ aptible log_drain:create:logdna HANDLE --url LOGDNA_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a LogDNA Log Drain
76
+ aptible log_drain:create:papertrail HANDLE --host PAPERTRAIL_HOST --port PAPERTRAIL_PORT --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Papertrail Log Drain
77
+ aptible log_drain:create:sumologic HANDLE --url SUMOLOGIC_URL --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Sumologic Drain
78
+ aptible log_drain:create:syslog HANDLE --host SYSLOG_HOST --port SYSLOG_PORT [--token TOKEN] --environment ENVIRONMENT [--drain-apps true/false] [--drain_databases true/false] [--drain_ephemeral_sessions true/false] [--drain_proxies true/false] # Create a Papertrail Log Drain
79
+ aptible log_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a log drain
80
+ aptible log_drain:list # List all Log Drains
81
+ aptible login # Log in to Aptible
82
+ aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
83
+ aptible metric_drain:create:datadog HANDLE --api_key DATADOG_API_KEY --environment ENVIRONMENT # Create a Datadog Metric Drain
84
+ aptible metric_drain:create:influxdb HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT # Create an InfluxDB Metric Drain
85
+ aptible metric_drain:create:influxdb:custom HANDLE --username USERNAME --password PASSWORD --url URL_INCLUDING_PORT # Create an InfluxDB Metric Drain
86
+ aptible metric_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a Metric Drain
87
+ aptible metric_drain:list # List all Metric Drains
88
+ aptible operation:cancel OPERATION_ID # Cancel a running operation
89
+ aptible rebuild # Rebuild an app, and restart its services
90
+ aptible restart # Restart all services associated with an app
91
+ aptible services # List Services for an App
92
+ aptible ssh [COMMAND] # Run a command against an app
93
+ aptible version # Print Aptible CLI version
81
94
  ```
82
95
  <!-- END USAGE -->
83
96
 
@@ -19,11 +19,12 @@ require_relative 'helpers/tunnel'
19
19
  require_relative 'helpers/system'
20
20
  require_relative 'helpers/security_key'
21
21
  require_relative 'helpers/config_path'
22
+ require_relative 'helpers/log_drain'
23
+ require_relative 'helpers/metric_drain'
22
24
 
23
25
  require_relative 'subcommands/apps'
24
26
  require_relative 'subcommands/config'
25
27
  require_relative 'subcommands/db'
26
- require_relative 'subcommands/domains'
27
28
  require_relative 'subcommands/environment'
28
29
  require_relative 'subcommands/logs'
29
30
  require_relative 'subcommands/rebuild'
@@ -35,6 +36,8 @@ require_relative 'subcommands/backup'
35
36
  require_relative 'subcommands/operation'
36
37
  require_relative 'subcommands/inspect'
37
38
  require_relative 'subcommands/endpoints'
39
+ require_relative 'subcommands/log_drain'
40
+ require_relative 'subcommands/metric_drain'
38
41
 
39
42
  module Aptible
40
43
  module CLI
@@ -48,7 +51,6 @@ module Aptible
48
51
  include Subcommands::Apps
49
52
  include Subcommands::Config
50
53
  include Subcommands::DB
51
- include Subcommands::Domains
52
54
  include Subcommands::Environment
53
55
  include Subcommands::Logs
54
56
  include Subcommands::Rebuild
@@ -60,6 +62,8 @@ module Aptible
60
62
  include Subcommands::Operation
61
63
  include Subcommands::Inspect
62
64
  include Subcommands::Endpoints
65
+ include Subcommands::LogDrain
66
+ include Subcommands::MetricDrain
63
67
 
64
68
  # Forward return codes on failures.
65
69
  def self.exit_on_failure?
@@ -0,0 +1,85 @@
1
+ module Aptible
2
+ module CLI
3
+ module Helpers
4
+ module LogDrain
5
+ include Helpers::Token
6
+
7
+ def create_log_drain(account, drain_opts)
8
+ drain = account.create_log_drain!(drain_opts)
9
+ op = drain.create_operation(type: :provision)
10
+
11
+ if op.errors.any?
12
+ # NOTE: If we fail to provision the log drain, we should try and
13
+ # clean it up immediately.
14
+ drain.create_operation(type: :deprovision)
15
+ raise Thor::Error, op.errors.full_messages.first
16
+ end
17
+
18
+ attach_to_operation_logs(op)
19
+ end
20
+
21
+ def create_https_based_log_drain(handle, options, url_format_msg: nil)
22
+ account = ensure_environment(options)
23
+ url = ensure_url(options, url_format_msg: url_format_msg)
24
+
25
+ opts = {
26
+ handle: handle,
27
+ url: url,
28
+ drain_apps: options[:drain_apps],
29
+ drain_databases: options[:drain_databases],
30
+ drain_ephemeral_sessions: options[:drain_ephemeral_sessions],
31
+ drain_proxies: options[:drain_proxies],
32
+ drain_type: :https_post
33
+ }
34
+ create_log_drain(account, opts)
35
+ end
36
+
37
+ def create_syslog_based_log_drain(handle, options)
38
+ account = ensure_environment(options)
39
+
40
+ opts = {
41
+ handle: handle,
42
+ drain_host: options[:host],
43
+ drain_port: options[:port],
44
+ logging_token: options[:token],
45
+ drain_apps: options[:drain_apps],
46
+ drain_databases: options[:drain_databases],
47
+ drain_ephemeral_sessions: options[:drain_ephemeral_sessions],
48
+ drain_proxies: options[:drain_proxies],
49
+ drain_type: :syslog_tls_tcp
50
+ }
51
+ create_log_drain(account, opts)
52
+ end
53
+
54
+ def ensure_url(options, url_format_msg: nil)
55
+ msg = '--url is required.'
56
+ msg = "#{msg} #{url_format_msg}" unless url_format_msg.nil?
57
+
58
+ url = options[:url]
59
+ raise Thor::Error, msg if url.nil?
60
+
61
+ # API already does url validation, so I'm not going
62
+ # to duplicate that logic here, even if it would
63
+ # get us an error faster
64
+ url
65
+ end
66
+
67
+ def ensure_log_drain(account, handle)
68
+ drains = account.log_drains.select { |d| d.handle == handle }
69
+
70
+ if drains.empty?
71
+ raise Thor::Error, "No drain found with handle #{handle}"
72
+ end
73
+
74
+ # Log Drain handles are globally unique, so this is excessive
75
+ unless drains.length == 1
76
+ raise Thor::Error, "#{drains.length} drains found with handle "\
77
+ "#{handle}"
78
+ end
79
+
80
+ drains.first
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,39 @@
1
+ module Aptible
2
+ module CLI
3
+ module Helpers
4
+ module MetricDrain
5
+ include Helpers::Token
6
+
7
+ def create_metric_drain(account, drain_opts)
8
+ drain = account.create_metric_drain!(drain_opts)
9
+ op = drain.create_operation(type: :provision)
10
+
11
+ if op.errors.any?
12
+ # NOTE: If we fail to provision the log drain, we should try and
13
+ # clean it up immediately.
14
+ drain.create_operation(type: :deprovision)
15
+ raise Thor::Error, op.errors.full_messages.first
16
+ end
17
+
18
+ attach_to_operation_logs(op)
19
+ end
20
+
21
+ def ensure_metric_drain(account, handle)
22
+ drains = account.metric_drains.select { |d| d.handle == handle }
23
+
24
+ if drains.empty?
25
+ raise Thor::Error, "No drain found with handle #{handle}"
26
+ end
27
+
28
+ # Metric Drain handles are globally unique, so this is excessive
29
+ unless drains.length == 1
30
+ raise Thor::Error, "#{drains.length} drains found with handle "\
31
+ "#{handle}"
32
+ end
33
+
34
+ drains.first
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -5,8 +5,18 @@ module Aptible
5
5
  NO_NESTING = Object.new.freeze
6
6
 
7
7
  def inject_backup(node, backup, include_db: false)
8
+ bu_operation = begin
9
+ backup.created_from_operation
10
+ rescue HyperResource::ClientError
11
+ nil
12
+ end
13
+
8
14
  origin = if backup.manual && !backup.copied_from
9
- "manual, #{backup.created_from_operation.user_email}"
15
+ if bu_operation
16
+ "manual, #{bu_operation.user_email}"
17
+ else
18
+ 'manual, unknown'
19
+ end
10
20
  elsif backup.manual && backup.copied_from
11
21
  'manual, copy'
12
22
  elsif backup.copied_from
@@ -40,10 +50,10 @@ module Aptible
40
50
  end
41
51
  end
42
52
 
43
- if backup.created_from_operation && \
53
+ if bu_operation && \
44
54
  backup.manual && !backup.copied_from
45
55
  node.keyed_object('created_from_operation', 'id') do |n|
46
- inject_operation(n, backup.created_from_operation)
56
+ inject_operation(n, bu_operation)
47
57
  end
48
58
  end
49
59
  end
@@ -196,6 +206,36 @@ module Aptible
196
206
  attach_service(node, service)
197
207
  end
198
208
 
209
+ def inject_log_drain(node, log_drain, account)
210
+ node.value('id', log_drain.id)
211
+ node.value('handle', log_drain.handle)
212
+ node.value('drain_type', log_drain.drain_type)
213
+ node.value('created_at', log_drain.created_at)
214
+ node.value('drain_apps', log_drain.drain_apps)
215
+ node.value('drain_databases', log_drain.drain_databases)
216
+ node.value('drain_ephemeral_sessions',
217
+ log_drain.drain_ephemeral_sessions)
218
+ node.value('drain_proxies', log_drain.drain_proxies)
219
+
220
+ optional_attrs = %w(drain_username drain_host drain_port url)
221
+ optional_attrs.each do |attr|
222
+ value = log_drain.attributes[attr]
223
+ node.value(attr, value) unless value.nil?
224
+ end
225
+
226
+ attach_account(node, account)
227
+ end
228
+
229
+ def inject_metric_drain(node, metric_drain, account)
230
+ node.value('id', metric_drain.id)
231
+ node.value('handle', metric_drain.handle)
232
+ node.value('drain_type', metric_drain.drain_type)
233
+ node.value('created_at', metric_drain.created_at)
234
+ node.value('drain_configuration', metric_drain.drain_configuration)
235
+
236
+ attach_account(node, account)
237
+ end
238
+
199
239
  private
200
240
 
201
241
  def attach_account(node, account)
@@ -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
- option :size, type: :numeric,
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
- if container_size.nil?
92
- m = 'Passing container size via the --size keyword ' \
93
- 'argument is deprecated, use --container-size'
94
- CLI.logger.warn(m)
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] || options[: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
- CLI.logger.warn([
48
- 'You have used the "--size" option to specify a disk size.',
49
- 'This option which be deprecated in a future version.',
50
- 'Please use the "--disk-size" option, instead.'
51
- ].join("\n")) if options[:size]
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
- attach_to_operation_logs(operation)
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