acquia_toolbelt 2.3.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -5
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/lib/acquia_toolbelt/cli/api.rb +33 -28
- data/lib/acquia_toolbelt/cli/auth.rb +8 -8
- data/lib/acquia_toolbelt/cli/database.rb +43 -43
- data/lib/acquia_toolbelt/cli/deploy.rb +4 -4
- data/lib/acquia_toolbelt/cli/domain.rb +24 -24
- data/lib/acquia_toolbelt/cli/environment.rb +16 -15
- data/lib/acquia_toolbelt/cli/file.rb +6 -6
- data/lib/acquia_toolbelt/cli/server.rb +25 -24
- data/lib/acquia_toolbelt/cli/site.rb +12 -7
- data/lib/acquia_toolbelt/cli/ssh.rb +22 -18
- data/lib/acquia_toolbelt/cli/svn.rb +15 -15
- data/lib/acquia_toolbelt/cli/task.rb +12 -14
- data/lib/acquia_toolbelt/cli/ui.rb +2 -2
- data/lib/acquia_toolbelt/cli.rb +49 -45
- data/lib/acquia_toolbelt/thor.rb +7 -7
- data/lib/acquia_toolbelt/version.rb +1 -1
- data/lib/acquia_toolbelt.rb +1 -1
- metadata +3 -3
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'netrc'
|
2
|
+
require 'faraday'
|
3
|
+
require 'json'
|
4
|
+
require 'acquia_toolbelt/version'
|
5
5
|
|
6
6
|
module AcquiaToolbelt
|
7
7
|
class CLI
|
8
8
|
class API
|
9
9
|
USER_AGENT = "AcquiaToolbelt/#{AcquiaToolbelt::VERSION}"
|
10
|
-
ENDPOINT =
|
11
|
-
ENDPOINT_VERSION =
|
10
|
+
ENDPOINT = 'https://cloudapi.acquia.com'
|
11
|
+
ENDPOINT_VERSION = 'v1'
|
12
12
|
|
13
13
|
# Internal: Send a request to the Acquia API.
|
14
14
|
#
|
@@ -25,59 +25,64 @@ module AcquiaToolbelt
|
|
25
25
|
# for the application.
|
26
26
|
#
|
27
27
|
# Retuns JSON object from the response body.
|
28
|
-
def self.request(resource, method =
|
29
|
-
|
28
|
+
def self.request(resource, method = 'GET', data = {}, parse_request = true)
|
29
|
+
# If the netrc file has incorrect permissions, let the user know.
|
30
|
+
begin
|
31
|
+
n = Netrc.read
|
32
|
+
rescue => e
|
33
|
+
puts e.message
|
34
|
+
end
|
30
35
|
|
31
36
|
# Make sure there is an entry for the Acquia API before generating the
|
32
37
|
# requests.
|
33
|
-
if n[
|
34
|
-
puts
|
35
|
-
puts
|
38
|
+
if n['cloudapi.acquia.com'].nil?
|
39
|
+
puts 'No entry for cloudapi.acquia.com within your netrc file.'
|
40
|
+
puts 'You can login/reset your user credentials by running `acquia auth:login`'
|
36
41
|
return
|
37
42
|
end
|
38
43
|
|
39
|
-
@acquia_user, @acquia_password = n[
|
44
|
+
@acquia_user, @acquia_password = n['cloudapi.acquia.com']
|
40
45
|
|
41
46
|
# Check if the user is behind a proxy and add the proxy settings if
|
42
47
|
# they are.
|
43
|
-
conn = (using_proxy?) ? Faraday.new(:proxy => ENV[
|
48
|
+
conn = (using_proxy?) ? Faraday.new(:proxy => ENV['HTTPS_PROXY']) : Faraday.new
|
44
49
|
conn.basic_auth(@acquia_user, @acquia_password)
|
45
50
|
|
46
51
|
# Be nice and send a user agent - help tracking and issue detection on
|
47
52
|
# Acquia's end as well as the client.
|
48
|
-
conn.headers[
|
53
|
+
conn.headers['User-Agent'] = "#{AcquiaToolbelt::CLI::API::USER_AGENT}"
|
49
54
|
|
50
55
|
case method
|
51
|
-
when
|
56
|
+
when 'GET'
|
52
57
|
response = conn.get "#{endpoint_uri}/#{resource}.json"
|
53
|
-
|
58
|
+
successful_response? response
|
54
59
|
|
55
60
|
if parse_request == true
|
56
61
|
JSON.parse(response.body)
|
57
62
|
else
|
58
63
|
response
|
59
64
|
end
|
60
|
-
when
|
65
|
+
when 'POST'
|
61
66
|
response = conn.post "#{endpoint_uri}/#{resource}.json", data.to_json
|
62
|
-
|
67
|
+
successful_response? response
|
63
68
|
|
64
69
|
if parse_request == true
|
65
70
|
JSON.parse(response.body)
|
66
71
|
else
|
67
72
|
response
|
68
73
|
end
|
69
|
-
when
|
74
|
+
when 'QUERY-STRING-POST'
|
70
75
|
response = conn.post "#{endpoint_uri}/#{resource}.json?#{data[:key]}=#{data[:value]}", data.to_json
|
71
|
-
|
76
|
+
successful_response? response
|
72
77
|
|
73
78
|
if parse_request == true
|
74
79
|
JSON.parse(response.body)
|
75
80
|
else
|
76
81
|
response
|
77
82
|
end
|
78
|
-
when
|
83
|
+
when 'DELETE'
|
79
84
|
response = conn.delete "#{endpoint_uri}/#{resource}.json"
|
80
|
-
|
85
|
+
successful_response? response
|
81
86
|
|
82
87
|
if parse_request == true
|
83
88
|
JSON.parse(response.body)
|
@@ -94,13 +99,13 @@ module AcquiaToolbelt
|
|
94
99
|
# a subscription and returns them for use in other methods.
|
95
100
|
#
|
96
101
|
# Returns an array of environments.
|
97
|
-
def self.
|
102
|
+
def self.environments
|
98
103
|
subscription = default_subscription
|
99
104
|
env_data = request "sites/#{subscription}/envs"
|
100
105
|
|
101
106
|
envs = []
|
102
107
|
env_data.each do |env|
|
103
|
-
envs << env[
|
108
|
+
envs << env['name']
|
104
109
|
end
|
105
110
|
|
106
111
|
envs
|
@@ -114,7 +119,7 @@ module AcquiaToolbelt
|
|
114
119
|
#
|
115
120
|
# Returns the first subscription name.
|
116
121
|
def self.default_subscription
|
117
|
-
sites = request
|
122
|
+
sites = request 'sites'
|
118
123
|
sites.first
|
119
124
|
end
|
120
125
|
|
@@ -133,7 +138,7 @@ module AcquiaToolbelt
|
|
133
138
|
#
|
134
139
|
# Return boolean based on whether HTTPS_PROXY is set.
|
135
140
|
def self.using_proxy?
|
136
|
-
ENV[
|
141
|
+
ENV['HTTPS_PROXY'] ? true : false
|
137
142
|
end
|
138
143
|
|
139
144
|
# Internal: Show the error message from the response.
|
@@ -143,7 +148,7 @@ module AcquiaToolbelt
|
|
143
148
|
#
|
144
149
|
# Returns string of the message.
|
145
150
|
def self.display_error(response)
|
146
|
-
"Oops, an error occurred! Reason: #{response[
|
151
|
+
"Oops, an error occurred! Reason: #{response['message']}"
|
147
152
|
end
|
148
153
|
|
149
154
|
# Internal: Ensure the response returns a HTTP 200.
|
@@ -153,7 +158,7 @@ module AcquiaToolbelt
|
|
153
158
|
# that won't complete.
|
154
159
|
#
|
155
160
|
# Returns false if the response code isn't a HTTP 200.
|
156
|
-
def self.
|
161
|
+
def self.successful_response?(response)
|
157
162
|
if response.status != 200
|
158
163
|
puts display_error(JSON.parse(response.body))
|
159
164
|
return
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'highline/import'
|
2
|
+
require 'netrc'
|
3
|
+
require 'acquia_toolbelt/cli'
|
4
4
|
|
5
5
|
module AcquiaToolbelt
|
6
6
|
class CLI
|
@@ -11,20 +11,20 @@ module AcquiaToolbelt
|
|
11
11
|
# requests.
|
12
12
|
#
|
13
13
|
# Returns a status message.
|
14
|
-
desc
|
14
|
+
desc 'login', 'Login to your Acquia account.'
|
15
15
|
def login
|
16
16
|
cli = HighLine.new
|
17
|
-
user = cli.ask(
|
18
|
-
password = cli.ask(
|
17
|
+
user = cli.ask('Enter your username: ')
|
18
|
+
password = cli.ask('Enter your password: ') { |q| q.echo = false }
|
19
19
|
|
20
20
|
# Update (or create if needed) the netrc file that will contain the user
|
21
21
|
# authentication details.
|
22
22
|
n = Netrc.read
|
23
23
|
n.new_item_prefix = "# This entry was added for connecting to the Acquia Cloud API\n"
|
24
|
-
n[
|
24
|
+
n['cloudapi.acquia.com'] = user, password
|
25
25
|
n.save
|
26
26
|
|
27
|
-
ui.success
|
27
|
+
ui.success 'Your user credentials have been successfully set.'
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -12,20 +12,20 @@ module AcquiaToolbelt
|
|
12
12
|
#
|
13
13
|
# Returns multiple lines.
|
14
14
|
def output_database_instance(database)
|
15
|
-
ui.say "> Username: #{database[
|
16
|
-
ui.say "> Password: #{database[
|
17
|
-
ui.say "> Host: #{database[
|
18
|
-
ui.say "> DB cluster: #{database[
|
19
|
-
ui.say "> Instance name: #{database[
|
15
|
+
ui.say "> Username: #{database['username']}"
|
16
|
+
ui.say "> Password: #{database['password']}"
|
17
|
+
ui.say "> Host: #{database['host']}"
|
18
|
+
ui.say "> DB cluster: #{database['db_cluster']}"
|
19
|
+
ui.say "> Instance name: #{database['instance_name']}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
# Public: Add a database to the subscription.
|
24
24
|
#
|
25
25
|
# Returns a status message.
|
26
|
-
desc
|
27
|
-
method_option :database, :type => :string, :aliases => %w(-d),
|
28
|
-
:desc =>
|
26
|
+
desc 'add', 'Add a database.'
|
27
|
+
method_option :database, :type => :string, :aliases => %w(-d),
|
28
|
+
:required => true, :desc => 'Name of the database to create.'
|
29
29
|
def add
|
30
30
|
if options[:subscription]
|
31
31
|
subscription = options[:subscription]
|
@@ -34,11 +34,11 @@ module AcquiaToolbelt
|
|
34
34
|
end
|
35
35
|
|
36
36
|
database = options[:database]
|
37
|
-
add_database = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/dbs",
|
37
|
+
add_database = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/dbs", 'POST', :db => "#{database}"
|
38
38
|
|
39
39
|
puts "#{add_database}"
|
40
40
|
|
41
|
-
if add_database[
|
41
|
+
if add_database['id']
|
42
42
|
ui.success "Database '#{database}' has been successfully created."
|
43
43
|
else
|
44
44
|
ui.fail AcquiaToolbelt::CLI::API.display_error(add_database)
|
@@ -48,13 +48,13 @@ module AcquiaToolbelt
|
|
48
48
|
# Public: Copy a database from one environment to another.
|
49
49
|
#
|
50
50
|
# Returns a status message.
|
51
|
-
desc
|
51
|
+
desc 'copy', 'Copy a database from one environment to another.'
|
52
52
|
method_option :database, :type => :string, :aliases => %w(-d), :required => true,
|
53
|
-
:desc =>
|
53
|
+
:desc => 'Name of the database to copy.'
|
54
54
|
method_option :origin, :type => :string, :aliases => %w(-o), :required => true,
|
55
|
-
:desc =>
|
55
|
+
:desc => 'Origin of the database to copy.'
|
56
56
|
method_option :target, :type => :string, :aliases => %w(-t), :required => true,
|
57
|
-
:desc =>
|
57
|
+
:desc => 'Target of where to copy the database.'
|
58
58
|
def copy
|
59
59
|
if options[:subscription]
|
60
60
|
subscription = options[:subscription]
|
@@ -65,7 +65,7 @@ module AcquiaToolbelt
|
|
65
65
|
database = options[:database]
|
66
66
|
origin = options[:origin]
|
67
67
|
target = options[:target]
|
68
|
-
copy_database = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/dbs/#{database}/db-copy/#{origin}/#{target}",
|
68
|
+
copy_database = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/dbs/#{database}/db-copy/#{origin}/#{target}", 'POST'
|
69
69
|
|
70
70
|
if copy_database["id"]
|
71
71
|
ui.success "Database '#{database}' has been copied from #{origin} to #{target}."
|
@@ -80,9 +80,9 @@ module AcquiaToolbelt
|
|
80
80
|
# environments.
|
81
81
|
#
|
82
82
|
# Returns a status message.
|
83
|
-
desc
|
84
|
-
method_option :database, :type => :string, :aliases => %w(-d),
|
85
|
-
:desc =>
|
83
|
+
desc 'delete', 'Delete a database.'
|
84
|
+
method_option :database, :type => :string, :aliases => %w(-d),
|
85
|
+
:required => true, :desc => 'Name of the database to delete.'
|
86
86
|
def delete
|
87
87
|
if options[:subscription]
|
88
88
|
subscription = options[:subscription]
|
@@ -91,9 +91,9 @@ module AcquiaToolbelt
|
|
91
91
|
end
|
92
92
|
|
93
93
|
database = options[:database]
|
94
|
-
delete_db = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/dbs/#{database}",
|
94
|
+
delete_db = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/dbs/#{database}", 'DELETE'
|
95
95
|
|
96
|
-
if delete_db[
|
96
|
+
if delete_db['id']
|
97
97
|
ui.success "Database '#{database}' has been successfully deleted."
|
98
98
|
else
|
99
99
|
ui.fail AcquiaToolbelt::CLI::API.display_error(delete_database)
|
@@ -103,9 +103,9 @@ module AcquiaToolbelt
|
|
103
103
|
# Public: List all databases available within a subscription.
|
104
104
|
#
|
105
105
|
# Returns a database listing.
|
106
|
-
desc
|
106
|
+
desc 'list', 'List all databases.'
|
107
107
|
method_option :database, :type => :string, :aliases => %w(-d),
|
108
|
-
:desc =>
|
108
|
+
:desc => 'Name of the database to view.'
|
109
109
|
def list
|
110
110
|
if options[:subscription]
|
111
111
|
subscription = options[:subscription]
|
@@ -128,7 +128,7 @@ module AcquiaToolbelt
|
|
128
128
|
databases = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/dbs"
|
129
129
|
databases.each do |db|
|
130
130
|
ui.say
|
131
|
-
ui.say "#{db[
|
131
|
+
ui.say "#{db['name']}"
|
132
132
|
output_database_instance(db)
|
133
133
|
end
|
134
134
|
|
@@ -137,7 +137,7 @@ module AcquiaToolbelt
|
|
137
137
|
databases = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/dbs"
|
138
138
|
ui.say
|
139
139
|
databases.each do |db|
|
140
|
-
say "> #{db[
|
140
|
+
say "> #{db['name']}"
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
@@ -145,9 +145,9 @@ module AcquiaToolbelt
|
|
145
145
|
# Public: Create a database instance backup.
|
146
146
|
#
|
147
147
|
# Returns a status message.
|
148
|
-
desc
|
149
|
-
method_option :database, :type => :string, :aliases => %w(-d),
|
150
|
-
:desc =>
|
148
|
+
desc 'backup', 'Create a new backup for a database.'
|
149
|
+
method_option :database, :type => :string, :aliases => %w(-d),
|
150
|
+
:required => true, :desc => 'Name of the database to backup.'
|
151
151
|
def backup
|
152
152
|
if options[:subscription]
|
153
153
|
subscription = options[:subscription]
|
@@ -157,7 +157,7 @@ module AcquiaToolbelt
|
|
157
157
|
|
158
158
|
database = options[:database]
|
159
159
|
environment = options[:environment]
|
160
|
-
create_backup = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/dbs/#{database}/backups",
|
160
|
+
create_backup = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/dbs/#{database}/backups", 'POST'
|
161
161
|
if create_backup["id"]
|
162
162
|
ui.success "The backup for '#{database}' in #{environment} has been started."
|
163
163
|
else
|
@@ -168,9 +168,9 @@ module AcquiaToolbelt
|
|
168
168
|
# Public: List available database backups.
|
169
169
|
#
|
170
170
|
# Returns all database backups.
|
171
|
-
desc
|
172
|
-
method_option :database, :type => :string, :aliases => %w(-d),
|
173
|
-
:desc =>
|
171
|
+
desc 'list-backups', 'List all database backups.'
|
172
|
+
method_option :database, :type => :string, :aliases => %w(-d),
|
173
|
+
:required => true, :desc => 'Name of the database to get the backup for.'
|
174
174
|
def list_backups
|
175
175
|
# Ensure we have an environment defined.
|
176
176
|
if options[:environment].nil?
|
@@ -189,24 +189,24 @@ module AcquiaToolbelt
|
|
189
189
|
backups = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/dbs/#{database}/backups"
|
190
190
|
backups.each do |backup|
|
191
191
|
ui.say
|
192
|
-
ui.say "> ID: #{backup[
|
193
|
-
ui.say "> MD5: #{backup[
|
194
|
-
ui.say "> Type: #{backup[
|
195
|
-
ui.say "> Path: #{backup[
|
196
|
-
ui.say "> Link: #{backup[
|
197
|
-
ui.say "> Started: #{Time.at(backup[
|
198
|
-
ui.say "> Completed: #{Time.at(backup[
|
192
|
+
ui.say "> ID: #{backup['id']}"
|
193
|
+
ui.say "> MD5: #{backup['checksum']}"
|
194
|
+
ui.say "> Type: #{backup['type']}"
|
195
|
+
ui.say "> Path: #{backup['path']}"
|
196
|
+
ui.say "> Link: #{backup['link']}"
|
197
|
+
ui.say "> Started: #{Time.at(backup['started'].to_i)}"
|
198
|
+
ui.say "> Completed: #{Time.at(backup['completed'].to_i)}"
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
202
|
# Public: Restore a database backup.
|
203
203
|
#
|
204
204
|
# Returns a status message.
|
205
|
-
desc
|
205
|
+
desc 'restore', 'Restore a database from a backup.'
|
206
206
|
method_option :id, :type => :string, :aliases => %w(-i),
|
207
|
-
:desc =>
|
207
|
+
:desc => 'Backup ID to restore.'
|
208
208
|
method_option :database, :type => :string, :aliases => %w(-d),
|
209
|
-
:desc =>
|
209
|
+
:desc => 'Name of the database to restore.'
|
210
210
|
def restore
|
211
211
|
# Ensure we have an environment defined.
|
212
212
|
if options[:environment].nil?
|
@@ -224,9 +224,9 @@ module AcquiaToolbelt
|
|
224
224
|
environment = options[:environment]
|
225
225
|
database = options[:database]
|
226
226
|
backup_id = options[:id]
|
227
|
-
restore_db = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/dbs/#{database}/backups/#{backup_id}/restore",
|
227
|
+
restore_db = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/dbs/#{database}/backups/#{backup_id}/restore", 'POST'
|
228
228
|
|
229
|
-
if restore_db[
|
229
|
+
if restore_db['id']
|
230
230
|
ui.success "Database backup #{backup_id} has been restored to '#{database}' in #{environment}."
|
231
231
|
else
|
232
232
|
ui.fail AcquiaToolbelt::CLI::API.display_error(restore_db)
|
@@ -4,9 +4,9 @@ module AcquiaToolbelt
|
|
4
4
|
# Public: Deploy a VCS branch or tag.
|
5
5
|
#
|
6
6
|
# Returns a status message.
|
7
|
-
desc
|
7
|
+
desc 'code', 'Deploy a VCS branch or tag to an environment.'
|
8
8
|
method_option :release, :type => :string, :aliases => %w(-r), :required => true,
|
9
|
-
:desc =>
|
9
|
+
:desc => 'Name of the release to deploy to the environment.'
|
10
10
|
def code
|
11
11
|
if options[:environment].nil?
|
12
12
|
ui.say "No value provided for required options '--environment'"
|
@@ -21,9 +21,9 @@ module AcquiaToolbelt
|
|
21
21
|
|
22
22
|
environment = options[:environment]
|
23
23
|
release = options[:release]
|
24
|
-
data = { :key =>
|
24
|
+
data = { :key => 'path', :value => "#{release}" }
|
25
25
|
|
26
|
-
deploy_code = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/code-deploy",
|
26
|
+
deploy_code = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/code-deploy", 'QUERY-STRING-POST', data
|
27
27
|
|
28
28
|
if deploy_code["id"]
|
29
29
|
ui.success "#{release} has been deployed to #{environment}."
|
@@ -8,13 +8,13 @@ module AcquiaToolbelt
|
|
8
8
|
def purge_domain(subscription, environment, domain)
|
9
9
|
# Ensure all the required fields are available.
|
10
10
|
if subscription.nil? || environment.nil? || domain.nil?
|
11
|
-
ui.fail
|
11
|
+
ui.fail 'Purge request is missing a required parameter.'
|
12
12
|
return
|
13
13
|
end
|
14
14
|
|
15
|
-
purge_request = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/domains/#{domain}/cache",
|
15
|
+
purge_request = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/domains/#{domain}/cache", 'DELETE'
|
16
16
|
|
17
|
-
if purge_request[
|
17
|
+
if purge_request['id']
|
18
18
|
ui.success "#{domain} has been successfully purged."
|
19
19
|
else
|
20
20
|
ui.fail AcquiaToolbelt::CLI::API.display_error(purge_request)
|
@@ -25,7 +25,7 @@ module AcquiaToolbelt
|
|
25
25
|
# Public: List all domains on a subscription.
|
26
26
|
#
|
27
27
|
# Returns all domains.
|
28
|
-
desc
|
28
|
+
desc 'list', 'List all domains.'
|
29
29
|
def list
|
30
30
|
# Set the subscription if it has been passed through, otherwise use the
|
31
31
|
# default.
|
@@ -40,7 +40,7 @@ module AcquiaToolbelt
|
|
40
40
|
environments = []
|
41
41
|
environments << options[:environment]
|
42
42
|
else
|
43
|
-
environments = AcquiaToolbelt::CLI::API.
|
43
|
+
environments = AcquiaToolbelt::CLI::API.environments
|
44
44
|
end
|
45
45
|
|
46
46
|
environments.each do |environment|
|
@@ -49,7 +49,7 @@ module AcquiaToolbelt
|
|
49
49
|
ui.say "Environment: #{environment}" unless options[:environment]
|
50
50
|
|
51
51
|
domains.each do |domain|
|
52
|
-
ui.say "> #{domain[
|
52
|
+
ui.say "> #{domain['name']}"
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -57,9 +57,9 @@ module AcquiaToolbelt
|
|
57
57
|
# Public: Add a domain to the subscription.
|
58
58
|
#
|
59
59
|
# Returns a status message.
|
60
|
-
desc
|
60
|
+
desc 'add', 'Add a domain.'
|
61
61
|
method_option :domain, :type => :string, :aliases => %w(-d), :required => true,
|
62
|
-
:desc =>
|
62
|
+
:desc => 'Full URL of the domain to add - No slashes or protocols required.'
|
63
63
|
def add
|
64
64
|
if options[:environment].nil?
|
65
65
|
ui.say "No value provided for required options '--environment'"
|
@@ -74,9 +74,9 @@ module AcquiaToolbelt
|
|
74
74
|
|
75
75
|
environment = options[:environment]
|
76
76
|
domain = options[:domain]
|
77
|
-
add_domain = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/domains/#{domain}",
|
77
|
+
add_domain = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/domains/#{domain}", 'POST'
|
78
78
|
|
79
|
-
if add_domain[
|
79
|
+
if add_domain['id']
|
80
80
|
ui.success "Domain #{domain} has been successfully added to #{environment}."
|
81
81
|
else
|
82
82
|
ui.fail AcquiaToolbelt::CLI::API.display_error(add_domain)
|
@@ -86,9 +86,9 @@ module AcquiaToolbelt
|
|
86
86
|
# Public: Delete a domain from an environment.
|
87
87
|
#
|
88
88
|
# Returns a status message.
|
89
|
-
desc
|
89
|
+
desc 'delete', 'Delete a domain.'
|
90
90
|
method_option :domain, :type => :string, :aliases => %w(-d), :required => true,
|
91
|
-
:desc =>
|
91
|
+
:desc => 'Full URL of the domain to delete - No slashes or protocols required.'
|
92
92
|
def delete
|
93
93
|
if options[:subscription]
|
94
94
|
subscription = options[:subscription]
|
@@ -98,7 +98,7 @@ module AcquiaToolbelt
|
|
98
98
|
|
99
99
|
environment = options[:environment]
|
100
100
|
domain = options[:domain]
|
101
|
-
delete_domain = AcquiaToolbelt::CLI::API.request "/sites/#{subscription}/envs/#{environment}/domains/#{domain}",
|
101
|
+
delete_domain = AcquiaToolbelt::CLI::API.request "/sites/#{subscription}/envs/#{environment}/domains/#{domain}", 'DELETE'
|
102
102
|
|
103
103
|
if delete_domain["id"]
|
104
104
|
ui.success "Domain #{domain} has been successfully deleted from #{environment}."
|
@@ -110,9 +110,9 @@ module AcquiaToolbelt
|
|
110
110
|
# Public: Purge a domains web cache.
|
111
111
|
#
|
112
112
|
# Returns a status message.
|
113
|
-
desc
|
113
|
+
desc 'purge', 'Purge a domain\'s web cache.'
|
114
114
|
method_option :domain, :type => :string, :aliases => %w(-d),
|
115
|
-
:desc =>
|
115
|
+
:desc => 'URL of the domain to purge.'
|
116
116
|
def purge
|
117
117
|
if options[:subscription]
|
118
118
|
subscription = options[:subscription]
|
@@ -135,10 +135,10 @@ module AcquiaToolbelt
|
|
135
135
|
if all_env_clear == "y"
|
136
136
|
domains = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/domains"
|
137
137
|
domains.each do |domain|
|
138
|
-
purge_domain("#{subscription}", "#{environment}", "#{domain[
|
138
|
+
purge_domain("#{subscription}", "#{environment}", "#{domain['name']}")
|
139
139
|
end
|
140
140
|
else
|
141
|
-
ui.info
|
141
|
+
ui.info 'Ok, no action has been taken.'
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|
@@ -146,13 +146,13 @@ module AcquiaToolbelt
|
|
146
146
|
# Public: Move domains from one environment to another.
|
147
147
|
#
|
148
148
|
# Returns a status message.
|
149
|
-
desc
|
149
|
+
desc 'move', 'Move a domain to another environment.'
|
150
150
|
method_option :domains, :type => :string, :aliases => %w(-d),
|
151
|
-
:desc =>
|
151
|
+
:desc => 'List of comma separated domains to move.'
|
152
152
|
method_option :origin, :type => :string, :aliases => %w(-o),
|
153
|
-
:desc =>
|
153
|
+
:desc => 'Origin environment to move the domains from.'
|
154
154
|
method_option :target, :type => :string, :aliases => %w(-t),
|
155
|
-
:desc =>
|
155
|
+
:desc => 'Target environment to move the domains to.'
|
156
156
|
def move
|
157
157
|
if options[:subscription]
|
158
158
|
subscription = options[:subscription]
|
@@ -160,13 +160,13 @@ module AcquiaToolbelt
|
|
160
160
|
subscription = AcquiaToolbelt::CLI::API.default_subscription
|
161
161
|
end
|
162
162
|
|
163
|
-
domains = options[:domains].split(
|
163
|
+
domains = options[:domains].split(',')
|
164
164
|
origin = options[:origin]
|
165
165
|
target = options[:target]
|
166
166
|
data = { :domains => domains }
|
167
167
|
|
168
|
-
move_domain = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/domain-move/#{origin}/#{target}",
|
169
|
-
if move_domain[
|
168
|
+
move_domain = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/domain-move/#{origin}/#{target}", 'POST', data
|
169
|
+
if move_domain['id']
|
170
170
|
ui.success "Domain move from #{origin} to #{target} has been successfully completed."
|
171
171
|
else
|
172
172
|
ui.fail AcquiaToolbelt::CLI::API.display_error(move_domain)
|