aptible-cli 0.18.1 → 0.19.1

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: 17c44d3802245955af8e9e71f728cb1b78540440106df5b5510f98677276652a
4
- data.tar.gz: 00ded45a48e4305d40bcb343242461c2c29738446a27f85479883ac1ca5e0052
3
+ metadata.gz: 8984c4633a4c6cfa79a8cba5fa5856079e4388677a4a6726f55eab3506ba82b5
4
+ data.tar.gz: d593ebd83e743458ea09ea1ffea94bf76679d6a10d12091d0f044701f85e4f5b
5
5
  SHA512:
6
- metadata.gz: 5f9683895ba7b8b2f2586eae6dc6dbb0b2472817bbb341609521ab7bdac72cff61719341d0545f2c0164f0f204a2041bdd2fad12029f86beae6d83482df5b386
7
- data.tar.gz: 81152b5c0b39dc12136ea7bfbdcd17c3ce3cc463582fa2f37bc4000fd715b5801c3fe21edb7ca32031fdac319406f4c64664f96f5a35ad0f15b2e05255f98933
6
+ metadata.gz: cc247fe45bb6ec934de142e4ca51e19c369a792ac92defc717b91436b293bb80c3fbbedeebc03efe4dd3cda4e3e983f8c53e95d8da5b30de53dc684bdd2d1a5e
7
+ data.tar.gz: ac409bc0d1e171f48f1a72035f31e8a69edc9b69e8aa586f6fcc70d52628ff698bc499f21e7b90fd38749b9779473ad6a9701606a843848217b1b3b732551f2c
data/README.md CHANGED
@@ -28,56 +28,70 @@ 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:database:modify --database DATABASE ENDPOINT_HOSTNAME # Modify 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 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
74
+ 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
75
+ 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
76
+ 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
77
+ 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
78
+ 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
79
+ 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
80
+ aptible log_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a log drain
81
+ aptible log_drain:list # List all Log Drains
82
+ aptible login # Log in to Aptible
83
+ aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
84
+ aptible metric_drain:create:datadog HANDLE --api_key DATADOG_API_KEY --site DATADOG_SITE --environment ENVIRONMENT # Create a Datadog Metric Drain
85
+ aptible metric_drain:create:influxdb HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT # Create an InfluxDB Metric Drain
86
+ aptible metric_drain:create:influxdb:custom HANDLE --username USERNAME --password PASSWORD --url URL_INCLUDING_PORT --db INFLUX_DATABASE_NAME --environment ENVIRONMENT # Create an InfluxDB Metric Drain
87
+ aptible metric_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a Metric Drain
88
+ aptible metric_drain:list # List all Metric Drains
89
+ aptible operation:cancel OPERATION_ID # Cancel a running operation
90
+ aptible rebuild # Rebuild an app, and restart its services
91
+ aptible restart # Restart all services associated with an app
92
+ aptible services # List Services for an App
93
+ aptible ssh [COMMAND] # Run a command against an app
94
+ aptible version # Print Aptible CLI version
81
95
  ```
82
96
  <!-- END USAGE -->
83
97
 
@@ -18,11 +18,13 @@ require_relative 'helpers/vhost/option_set_builder'
18
18
  require_relative 'helpers/tunnel'
19
19
  require_relative 'helpers/system'
20
20
  require_relative 'helpers/security_key'
21
+ require_relative 'helpers/config_path'
22
+ require_relative 'helpers/log_drain'
23
+ require_relative 'helpers/metric_drain'
21
24
 
22
25
  require_relative 'subcommands/apps'
23
26
  require_relative 'subcommands/config'
24
27
  require_relative 'subcommands/db'
25
- require_relative 'subcommands/domains'
26
28
  require_relative 'subcommands/environment'
27
29
  require_relative 'subcommands/logs'
28
30
  require_relative 'subcommands/rebuild'
@@ -34,6 +36,8 @@ require_relative 'subcommands/backup'
34
36
  require_relative 'subcommands/operation'
35
37
  require_relative 'subcommands/inspect'
36
38
  require_relative 'subcommands/endpoints'
39
+ require_relative 'subcommands/log_drain'
40
+ require_relative 'subcommands/metric_drain'
37
41
 
38
42
  module Aptible
39
43
  module CLI
@@ -43,10 +47,10 @@ module Aptible
43
47
  include Helpers::Token
44
48
  include Helpers::Ssh
45
49
  include Helpers::System
50
+ include Helpers::ConfigPath
46
51
  include Subcommands::Apps
47
52
  include Subcommands::Config
48
53
  include Subcommands::DB
49
- include Subcommands::Domains
50
54
  include Subcommands::Environment
51
55
  include Subcommands::Logs
52
56
  include Subcommands::Rebuild
@@ -58,6 +62,8 @@ module Aptible
58
62
  include Subcommands::Operation
59
63
  include Subcommands::Inspect
60
64
  include Subcommands::Endpoints
65
+ include Subcommands::LogDrain
66
+ include Subcommands::MetricDrain
61
67
 
62
68
  # Forward return codes on failures.
63
69
  def self.exit_on_failure?
@@ -209,7 +215,7 @@ module Aptible
209
215
  # further: to do so, edit the file `.aptible/nag_toolbelt` and put a
210
216
  # timestamp far into the future. For example, writing 1577836800 will
211
217
  # disable the warning until 2020.
212
- nag_file = File.join ENV['HOME'], '.aptible', 'nag_toolbelt'
218
+ nag_file = File.join aptible_config_path, 'nag_toolbelt'
213
219
  nag_frequency = 12.hours
214
220
 
215
221
  last_nag = begin
@@ -0,0 +1,11 @@
1
+ module Aptible
2
+ module CLI
3
+ module Helpers
4
+ module ConfigPath
5
+ def aptible_config_path
6
+ ENV['APTIBLE_CONFIG_PATH'] || (File.join ENV['HOME'], '.aptible')
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -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
@@ -1,7 +1,11 @@
1
+ require_relative 'config_path'
2
+
1
3
  module Aptible
2
4
  module CLI
3
5
  module Helpers
4
6
  module Ssh
7
+ include Helpers::ConfigPath
8
+
5
9
  def connect_to_ssh_portal(operation, *extra_ssh_args)
6
10
  # NOTE: This is a little tricky to get rigt, so before you make any
7
11
  # changes, read this.
@@ -126,7 +130,7 @@ module Aptible
126
130
  end
127
131
 
128
132
  def ssh_dir
129
- File.join ENV['HOME'], '.aptible', 'ssh'
133
+ File.join aptible_config_path, 'ssh'
130
134
  end
131
135
 
132
136
  def ssh_config_file
@@ -1,9 +1,13 @@
1
1
  require 'aptible/auth'
2
2
 
3
+ require_relative 'config_path'
4
+
3
5
  module Aptible
4
6
  module CLI
5
7
  module Helpers
6
8
  module Token
9
+ include Helpers::ConfigPath
10
+
7
11
  TOKEN_ENV_VAR = 'APTIBLE_ACCESS_TOKEN'.freeze
8
12
 
9
13
  def fetch_token
@@ -40,7 +44,7 @@ module Aptible
40
44
  end
41
45
 
42
46
  def token_file
43
- File.join ENV['HOME'], '.aptible', 'tokens.json'
47
+ File.join(aptible_config_path, 'tokens.json').freeze
44
48
  end
45
49
  end
46
50
  end
@@ -22,7 +22,9 @@ module Aptible
22
22
  thor.instance_exec(self) do |builder|
23
23
  option :environment
24
24
 
25
- if builder.app?
25
+ if builder.database?
26
+ option :database
27
+ elsif builder.app?
26
28
  app_options
27
29
 
28
30
  if builder.create?
@@ -32,11 +34,6 @@ module Aptible
32
34
  desc: 'Enable Default Domain on this Endpoint'
33
35
  )
34
36
 
35
- option(
36
- :internal,
37
- type: :boolean,
38
- desc: 'Restrict this Endpoint to internal traffic'
39
- )
40
37
  end
41
38
 
42
39
  if builder.ports?
@@ -56,6 +53,14 @@ module Aptible
56
53
  end
57
54
  end
58
55
 
56
+ if builder.create?
57
+ option(
58
+ :internal,
59
+ type: :boolean,
60
+ desc: 'Restrict this Endpoint to internal traffic'
61
+ )
62
+ end
63
+
59
64
  option(
60
65
  :ip_whitelist,
61
66
  type: :array,
@@ -151,6 +156,12 @@ module Aptible
151
156
  end
152
157
 
153
158
  options.delete(:app)
159
+ elsif database?
160
+ params[:internal] = options.delete(:internal) do
161
+ create? ? false : nil
162
+ end
163
+
164
+ options.delete(:database)
154
165
  else
155
166
  params[:internal] = false
156
167
  end
@@ -5,8 +5,27 @@ 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
+
14
+ origin = if backup.manual && !backup.copied_from
15
+ if bu_operation
16
+ "manual, #{bu_operation.user_email}"
17
+ else
18
+ 'manual, unknown'
19
+ end
20
+ elsif backup.manual && backup.copied_from
21
+ 'manual, copy'
22
+ elsif backup.copied_from
23
+ 'automatic, copy'
24
+ else
25
+ 'automatic'
26
+ end
8
27
  description = "#{backup.id}: #{backup.created_at}, " \
9
- "#{backup.aws_region}"
28
+ "#{backup.aws_region}, #{origin}"
10
29
 
11
30
  if include_db
12
31
  db = backup.database_with_deleted
@@ -30,6 +49,13 @@ module Aptible
30
49
  inject_backup(n, backup.copied_from)
31
50
  end
32
51
  end
52
+
53
+ if bu_operation && \
54
+ backup.manual && !backup.copied_from
55
+ node.keyed_object('created_from_operation', 'id') do |n|
56
+ inject_operation(n, bu_operation)
57
+ end
58
+ end
33
59
  end
34
60
 
35
61
  def inject_deleted_database(node, database, account)
@@ -49,7 +75,9 @@ module Aptible
49
75
  def inject_operation(node, operation)
50
76
  node.value('id', operation.id)
51
77
  node.value('status', operation.status)
52
- node.value('git_ref', operation.git_ref)
78
+ if %w(deploy rebuild).include?(operation.type)
79
+ node.value('git_ref', operation.git_ref)
80
+ end
53
81
  node.value('user_email', operation.user_email)
54
82
  node.value('created_at', operation.created_at)
55
83
  end
@@ -103,7 +131,7 @@ module Aptible
103
131
  node.value('disk_modification_progress',
104
132
  database.disk.modification_progress)
105
133
  node.value('disk_modification_status', database.disk.status)
106
- node.value('disk_provisioned_iops', database.disk.provisioned_iops)
134
+ node.value('disk_provisioned_iops', database.disk.baseline_iops)
107
135
  end
108
136
 
109
137
  if database.service
@@ -178,6 +206,36 @@ module Aptible
178
206
  attach_service(node, service)
179
207
  end
180
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
+
181
239
  private
182
240
 
183
241
  def attach_account(node, account)