rhc 1.11.4 → 1.12.4
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.
- data/autocomplete/rhc_bash +39 -23
- data/features/domain.feature +8 -3
- data/features/lib/rhc_helper/commandify.rb +6 -0
- data/features/lib/rhc_helper/domain.rb +1 -1
- data/features/step_definitions/domain_steps.rb +9 -4
- data/lib/rhc/auth/basic.rb +4 -2
- data/lib/rhc/cli.rb +1 -0
- data/lib/rhc/commands/apps.rb +2 -4
- data/lib/rhc/commands/cartridge.rb +1 -0
- data/lib/rhc/commands/domain.rb +25 -11
- data/lib/rhc/commands/port_forward.rb +0 -1
- data/lib/rhc/commands/sshkey.rb +1 -1
- data/lib/rhc/helpers.rb +1 -0
- data/lib/rhc/highline_extensions.rb +2 -1
- data/lib/rhc/output_helpers.rb +21 -0
- data/lib/rhc/rest.rb +4 -2
- data/lib/rhc/rest/api.rb +9 -11
- data/lib/rhc/rest/application.rb +4 -0
- data/lib/rhc/rest/base.rb +11 -1
- data/lib/rhc/rest/cartridge.rb +1 -1
- data/lib/rhc/rest/client.rb +52 -29
- data/lib/rhc/rest/domain.rb +11 -1
- data/lib/rhc/rest/httpclient.rb +125 -0
- data/lib/rhc/rest/mock.rb +32 -8
- data/spec/rhc/auth_spec.rb +29 -22
- data/spec/rhc/command_spec.rb +13 -9
- data/spec/rhc/commands/account_spec.rb +2 -2
- data/spec/rhc/commands/app_spec.rb +9 -9
- data/spec/rhc/commands/authorization_spec.rb +11 -11
- data/spec/rhc/commands/cartridge_spec.rb +3 -3
- data/spec/rhc/commands/domain_spec.rb +51 -1
- data/spec/rhc/commands/logout_spec.rb +3 -3
- data/spec/rhc/commands/port_forward_spec.rb +7 -7
- data/spec/rhc/commands/server_spec.rb +2 -2
- data/spec/rhc/commands/setup_spec.rb +6 -6
- data/spec/rhc/commands/snapshot_spec.rb +10 -10
- data/spec/rhc/helpers_spec.rb +6 -6
- data/spec/rhc/rest_application_spec.rb +11 -11
- data/spec/rhc/rest_client_spec.rb +148 -36
- data/spec/rhc/rest_spec.rb +3 -3
- data/spec/rhc/wizard_spec.rb +20 -20
- data/spec/spec_helper.rb +52 -3
- metadata +5 -4
data/autocomplete/rhc_bash
CHANGED
|
@@ -10,9 +10,9 @@ _rhc()
|
|
|
10
10
|
if [[ "$cur" == -* ]]; then
|
|
11
11
|
opts="--always-prefix --clean --config --debug --insecure --limit --mock --noprompt --password --raw --rhlogin --server --ssl-ca-file --ssl-client-cert-file --ssl-version --timeout --token"
|
|
12
12
|
elif [ -z $cur ]; then
|
|
13
|
-
opts="account alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-create app-delete app-force-stop app-reload app-restart app-show app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage domain domain-create domain-delete domain-show domain-update git-clone logout port-forward server setup snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show tail threaddump"
|
|
13
|
+
opts="account alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-create app-delete app-force-stop app-reload app-restart app-show app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage domain domain-create domain-delete domain-list domain-show domain-update git-clone logout port-forward server setup snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show tail threaddump"
|
|
14
14
|
else
|
|
15
|
-
opts="account account-logout add-alias add-authorization add-cartridge add-sshkey alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert aliases app app-create app-delete app-force-stop app-reload app-restart app-show app-snapshot app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list authorizations cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage cartridges create-app create-domain delete-all-authorization delete-app delete-authorization delete-cert-alias delete-domain domain domain-create domain-delete domain-show domain-update force-stop-app git-clone list-alias list-authorization list-cartridge list-sshkey logout port-forward reload-app reload-cartridge remove-alias remove-cartridge remove-sshkey restart-app restart-cartridge restore-snapshot save-snapshot scale-cartridge server setup show-app show-cartridge show-domain show-sshkey snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-
|
|
15
|
+
opts="account account-logout add-alias add-authorization add-cartridge add-sshkey alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert aliases app app-create app-delete app-force-stop app-reload app-restart app-show app-snapshot app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list authorizations cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage cartridges create-app create-domain delete-all-authorization delete-app delete-authorization delete-cert-alias delete-domain domain domain-create domain-delete domain-list domain-show domain-update domains force-stop-app git-clone list-alias list-authorization list-cartridge list-domain list-sshkey logout port-forward reload-app reload-cartridge remove-alias remove-cartridge remove-sshkey restart-app restart-cartridge restore-snapshot save-snapshot scale-cartridge server setup show-app show-cartridge show-domain show-sshkey snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show start-app start-cartridge status-cartridge stop-app stop-cartridge storage-cartridge tail threaddump tidy-app update-cert-alias update-domain"
|
|
16
16
|
fi
|
|
17
17
|
else
|
|
18
18
|
prev="${COMP_WORDS[@]:0:COMP_CWORD}"
|
|
@@ -696,7 +696,7 @@ _rhc()
|
|
|
696
696
|
if [[ "$cur" == -* ]]; then
|
|
697
697
|
opts=""
|
|
698
698
|
else
|
|
699
|
-
opts="create update show delete"
|
|
699
|
+
opts="create update show list delete"
|
|
700
700
|
fi
|
|
701
701
|
;;
|
|
702
702
|
|
|
@@ -716,9 +716,17 @@ _rhc()
|
|
|
716
716
|
fi
|
|
717
717
|
;;
|
|
718
718
|
|
|
719
|
-
"rhc domain
|
|
719
|
+
"rhc domain list")
|
|
720
720
|
if [[ "$cur" == -* ]]; then
|
|
721
|
+
opts="--mine"
|
|
722
|
+
else
|
|
721
723
|
opts=""
|
|
724
|
+
fi
|
|
725
|
+
;;
|
|
726
|
+
|
|
727
|
+
"rhc domain show")
|
|
728
|
+
if [[ "$cur" == -* ]]; then
|
|
729
|
+
opts="--namespace"
|
|
722
730
|
else
|
|
723
731
|
opts=""
|
|
724
732
|
fi
|
|
@@ -748,9 +756,17 @@ _rhc()
|
|
|
748
756
|
fi
|
|
749
757
|
;;
|
|
750
758
|
|
|
751
|
-
"rhc domain-
|
|
759
|
+
"rhc domain-list")
|
|
752
760
|
if [[ "$cur" == -* ]]; then
|
|
761
|
+
opts="--mine"
|
|
762
|
+
else
|
|
753
763
|
opts=""
|
|
764
|
+
fi
|
|
765
|
+
;;
|
|
766
|
+
|
|
767
|
+
"rhc domain-show")
|
|
768
|
+
if [[ "$cur" == -* ]]; then
|
|
769
|
+
opts="--namespace"
|
|
754
770
|
else
|
|
755
771
|
opts=""
|
|
756
772
|
fi
|
|
@@ -764,6 +780,14 @@ _rhc()
|
|
|
764
780
|
fi
|
|
765
781
|
;;
|
|
766
782
|
|
|
783
|
+
"rhc domains")
|
|
784
|
+
if [[ "$cur" == -* ]]; then
|
|
785
|
+
opts="--mine"
|
|
786
|
+
else
|
|
787
|
+
opts=""
|
|
788
|
+
fi
|
|
789
|
+
;;
|
|
790
|
+
|
|
767
791
|
"rhc force-stop-app")
|
|
768
792
|
if [[ "$cur" == -* ]]; then
|
|
769
793
|
opts="--app --namespace"
|
|
@@ -804,6 +828,14 @@ _rhc()
|
|
|
804
828
|
fi
|
|
805
829
|
;;
|
|
806
830
|
|
|
831
|
+
"rhc list-domain")
|
|
832
|
+
if [[ "$cur" == -* ]]; then
|
|
833
|
+
opts="--mine"
|
|
834
|
+
else
|
|
835
|
+
opts=""
|
|
836
|
+
fi
|
|
837
|
+
;;
|
|
838
|
+
|
|
807
839
|
"rhc list-sshkey")
|
|
808
840
|
if [[ "$cur" == -* ]]; then
|
|
809
841
|
opts=""
|
|
@@ -942,7 +974,7 @@ _rhc()
|
|
|
942
974
|
|
|
943
975
|
"rhc show-domain")
|
|
944
976
|
if [[ "$cur" == -* ]]; then
|
|
945
|
-
opts=""
|
|
977
|
+
opts="--namespace"
|
|
946
978
|
else
|
|
947
979
|
opts=""
|
|
948
980
|
fi
|
|
@@ -1008,7 +1040,7 @@ _rhc()
|
|
|
1008
1040
|
if [[ "$cur" == -* ]]; then
|
|
1009
1041
|
opts=""
|
|
1010
1042
|
else
|
|
1011
|
-
opts="list show add
|
|
1043
|
+
opts="list show add remove"
|
|
1012
1044
|
fi
|
|
1013
1045
|
;;
|
|
1014
1046
|
|
|
@@ -1020,14 +1052,6 @@ _rhc()
|
|
|
1020
1052
|
fi
|
|
1021
1053
|
;;
|
|
1022
1054
|
|
|
1023
|
-
"rhc sshkey delete")
|
|
1024
|
-
if [[ "$cur" == -* ]]; then
|
|
1025
|
-
opts=""
|
|
1026
|
-
else
|
|
1027
|
-
opts=""
|
|
1028
|
-
fi
|
|
1029
|
-
;;
|
|
1030
|
-
|
|
1031
1055
|
"rhc sshkey list")
|
|
1032
1056
|
if [[ "$cur" == -* ]]; then
|
|
1033
1057
|
opts=""
|
|
@@ -1060,14 +1084,6 @@ _rhc()
|
|
|
1060
1084
|
fi
|
|
1061
1085
|
;;
|
|
1062
1086
|
|
|
1063
|
-
"rhc sshkey-delete")
|
|
1064
|
-
if [[ "$cur" == -* ]]; then
|
|
1065
|
-
opts=""
|
|
1066
|
-
else
|
|
1067
|
-
opts=""
|
|
1068
|
-
fi
|
|
1069
|
-
;;
|
|
1070
|
-
|
|
1071
1087
|
"rhc sshkey-list")
|
|
1072
1088
|
if [[ "$cur" == -* ]]; then
|
|
1073
1089
|
opts=""
|
data/features/domain.feature
CHANGED
|
@@ -10,14 +10,19 @@ Feature: Existing Domain Operations
|
|
|
10
10
|
When domain is updated
|
|
11
11
|
Then the domain should be reserved
|
|
12
12
|
|
|
13
|
-
Scenario: Domain
|
|
13
|
+
Scenario: Domain List
|
|
14
14
|
When rhc domain is run
|
|
15
|
+
When rhc domain list is run
|
|
16
|
+
Then the default domain action output should equal the list action output
|
|
17
|
+
|
|
18
|
+
Scenario: Domain Show
|
|
15
19
|
When rhc domain show is run
|
|
16
|
-
Then the
|
|
20
|
+
Then the domain show command output should show the domain
|
|
21
|
+
Then the domain command should exit with an exitcode of 0
|
|
17
22
|
|
|
18
23
|
Scenario: Domain Create Fails
|
|
19
24
|
When rhc domain create is called
|
|
20
|
-
Then the domain command should
|
|
25
|
+
Then the domain command should exit with an exitcode of 1
|
|
21
26
|
|
|
22
27
|
Scenario: Domain Delete
|
|
23
28
|
When domain is deleted
|
|
@@ -65,6 +65,8 @@ module RHCHelper
|
|
|
65
65
|
case cmd
|
|
66
66
|
when /app delete/
|
|
67
67
|
args << "--confirm "
|
|
68
|
+
when /domain list/
|
|
69
|
+
# domain list doesn't take arguments
|
|
68
70
|
when /domain show/
|
|
69
71
|
# domain show doesn't take arguments
|
|
70
72
|
when /domain update/
|
|
@@ -174,6 +176,10 @@ module RHCHelper
|
|
|
174
176
|
@domain_output = stdout
|
|
175
177
|
end
|
|
176
178
|
|
|
179
|
+
def domain_list_callback(exitcode, stdout, stderr, arg)
|
|
180
|
+
@domain_list_output = stdout
|
|
181
|
+
end
|
|
182
|
+
|
|
177
183
|
def domain_show_callback(exitcode, stdout, stderr, arg)
|
|
178
184
|
@domain_show_output = stdout
|
|
179
185
|
end
|
|
@@ -27,18 +27,23 @@ When /^rhc domain (.*)is run$/ do |action|
|
|
|
27
27
|
Domain.send(:"#{cmd}")
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
Then /^the default domain action output should equal the
|
|
30
|
+
Then /^the default domain action output should equal the list action output$/ do
|
|
31
31
|
Domain.domain_output.should match($namespace)
|
|
32
32
|
|
|
33
33
|
domain_output = Domain.domain_output.lines.sort
|
|
34
|
-
|
|
34
|
+
domain_list_output = Domain.domain_list_output.lines.sort
|
|
35
35
|
|
|
36
36
|
# check line by line while ignoring debug output which is timestamped
|
|
37
|
-
domain_output.zip(
|
|
37
|
+
domain_output.zip(domain_list_output) do |a, b|
|
|
38
38
|
a.should == b unless a.match("DEBUG")
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
Then /^the domain show command output should show the domain$/ do
|
|
43
|
+
domain_show_output = Domain.domain_show_output.lines
|
|
44
|
+
domain_show_output.find {|line| line["Domain #{$namespace}"] }.should be_true, "Unable to find \"Domain #{$namespace}\" in #{domain_show_output.inspect}"
|
|
45
|
+
end
|
|
46
|
+
|
|
42
47
|
Then /^the domain should be reserved?$/ do
|
|
43
48
|
# Sleep to allow DNS to propogate
|
|
44
49
|
sleep 5
|
|
@@ -54,7 +59,7 @@ Then /^the domain should be reserved?$/ do
|
|
|
54
59
|
resolved.should be_true, 'Not able to lookup DNS TXT record in time.'
|
|
55
60
|
end
|
|
56
61
|
|
|
57
|
-
Then /^the domain command should
|
|
62
|
+
Then /^the domain command should exit with an exitcode of (\d*)$/ do |exitcode|
|
|
58
63
|
exitcode = exitcode.to_i
|
|
59
64
|
Domain.exitcode.should == exitcode
|
|
60
65
|
end
|
data/lib/rhc/auth/basic.rb
CHANGED
|
@@ -13,8 +13,10 @@ module RHC::Auth
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def to_request(request)
|
|
16
|
-
request[:user] ||=
|
|
17
|
-
|
|
16
|
+
request[:user] ||=
|
|
17
|
+
lambda{ username || (request[:lazy_auth] != true && ask_username) || nil }
|
|
18
|
+
request[:password] ||=
|
|
19
|
+
lambda{ password || (username? && request[:lazy_auth] != true && ask_password) || nil }
|
|
18
20
|
request
|
|
19
21
|
end
|
|
20
22
|
|
data/lib/rhc/cli.rb
CHANGED
|
@@ -15,6 +15,7 @@ module RHC
|
|
|
15
15
|
|
|
16
16
|
def self.set_terminal
|
|
17
17
|
$terminal.wrap_at = HighLine::SystemExtensions.terminal_size.first rescue 80 if $stdin.tty?
|
|
18
|
+
$terminal.wrap_at = nil if $terminal.wrap_at == 0
|
|
18
19
|
#$terminal.page_at = :auto if $stdin.tty? and $stdout.tty?
|
|
19
20
|
# FIXME: ANSI terminals are not default on windows but we may just be
|
|
20
21
|
# hitting a bug in highline if windows does support another method.
|
data/lib/rhc/commands/apps.rb
CHANGED
|
@@ -5,11 +5,9 @@ module RHC::Commands
|
|
|
5
5
|
summary "List all your applications"
|
|
6
6
|
description "Display the list of applications that you own. Includes information about each application."
|
|
7
7
|
def run
|
|
8
|
-
|
|
8
|
+
applications = rest_client.applications(:include => :cartridges).sort
|
|
9
9
|
|
|
10
|
-
info "In order to deploy applications, you must create a domain with 'rhc setup' or 'rhc create-domain'." and return 1 if domains.empty?
|
|
11
|
-
|
|
12
|
-
applications = domains.map{ |d| d.applications(:include => :cartridges) }.flatten.sort
|
|
10
|
+
info "In order to deploy applications, you must create a domain with 'rhc setup' or 'rhc create-domain'." and return 1 if applications.empty? && rest_client.domains.empty?
|
|
13
11
|
|
|
14
12
|
applications.each{ |a| display_app(a, a.cartridges) }.blank? and
|
|
15
13
|
info "No applications. Use 'rhc create-app'." and
|
|
@@ -33,6 +33,7 @@ module RHC::Commands
|
|
|
33
33
|
default_action :list
|
|
34
34
|
|
|
35
35
|
summary "List available cartridges"
|
|
36
|
+
syntax ''
|
|
36
37
|
option ["-v", "--verbose"], "Display more details about each cartridge"
|
|
37
38
|
alias_action :"app cartridge list", :root_command => true, :deprecated => true
|
|
38
39
|
alias_action :"cartridges", :root_command => true
|
data/lib/rhc/commands/domain.rb
CHANGED
|
@@ -13,9 +13,9 @@ module RHC::Commands
|
|
|
13
13
|
|
|
14
14
|
http://<appname>-test.rhcloud.com
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Each account may have access to one or more domains shared by others.
|
|
17
17
|
DESC
|
|
18
|
-
default_action :
|
|
18
|
+
default_action :list
|
|
19
19
|
|
|
20
20
|
summary "Define a namespace for your applications to share."
|
|
21
21
|
syntax "<namespace>"
|
|
@@ -50,21 +50,18 @@ module RHC::Commands
|
|
|
50
50
|
0
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
summary "Display
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
summary "Display a domain and its applications"
|
|
54
|
+
argument :namespace, "Namespace of the domain", ["-n", "--namespace NAME"], :optional => true
|
|
55
|
+
def show(namespace)
|
|
56
|
+
domain = (rest_client.find_domain(namespace) if namespace) || rest_client.domains.first
|
|
56
57
|
|
|
57
58
|
warn "In order to deploy applications, you must create a domain with 'rhc setup' or 'rhc create-domain'." and return 1 unless domain
|
|
58
59
|
|
|
59
60
|
applications = domain.applications(:include => :cartridges)
|
|
61
|
+
display_domain(domain, applications)
|
|
60
62
|
|
|
61
63
|
if applications.present?
|
|
62
|
-
|
|
63
|
-
applications.each do |a|
|
|
64
|
-
display_app(a,a.cartridges)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
success "You have #{applications.length} applications in your domain."
|
|
64
|
+
success "You have #{pluralize(applications.length, 'application')} in your domain."
|
|
68
65
|
else
|
|
69
66
|
success "The domain #{domain.id} exists but has no applications. You can use 'rhc create-app' to create a new application."
|
|
70
67
|
end
|
|
@@ -72,6 +69,23 @@ module RHC::Commands
|
|
|
72
69
|
0
|
|
73
70
|
end
|
|
74
71
|
|
|
72
|
+
summary "Display all domains you have access to"
|
|
73
|
+
option ['--mine'], "Display only domains you own"
|
|
74
|
+
alias_action :domains, :root_command => true
|
|
75
|
+
def list
|
|
76
|
+
domains = rest_client.send(options.mine ? :owned_domains : :domains)
|
|
77
|
+
|
|
78
|
+
warn "In order to deploy applications, you must create a domain with 'rhc setup' or 'rhc create-domain'." and return 1 unless domains.present?
|
|
79
|
+
|
|
80
|
+
domains.each do |d|
|
|
81
|
+
display_domain(d)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
success "You have access to #{pluralize(domains.length, 'domain')}."
|
|
85
|
+
|
|
86
|
+
0
|
|
87
|
+
end
|
|
88
|
+
|
|
75
89
|
summary "DEPRECATED use 'setup' instead"
|
|
76
90
|
deprecated 'rhc setup'
|
|
77
91
|
# :nocov:
|
data/lib/rhc/commands/sshkey.rb
CHANGED
|
@@ -68,7 +68,7 @@ module RHC::Commands
|
|
|
68
68
|
|
|
69
69
|
summary 'Remove SSH key from your account'
|
|
70
70
|
syntax '<name>'
|
|
71
|
-
alias_action :delete
|
|
71
|
+
alias_action :delete, :deprecated => true
|
|
72
72
|
argument :name, 'Name of SSH key to remove'
|
|
73
73
|
def remove(name)
|
|
74
74
|
say "Removing the key '#{name} ... "
|
data/lib/rhc/helpers.rb
CHANGED
|
@@ -257,9 +257,10 @@ class HighLine::Header < Struct.new(:text, :width, :indent, :color)
|
|
|
257
257
|
def rows
|
|
258
258
|
@rows ||= begin
|
|
259
259
|
if !width || width == 0
|
|
260
|
-
[text.is_a?(Array) ? text.join(' ') : text]
|
|
260
|
+
[text.is_a?(Array) ? text.compact.join(' ') : text]
|
|
261
261
|
|
|
262
262
|
elsif text.is_a? Array
|
|
263
|
+
text.compact!
|
|
263
264
|
widths = text.map{ |s| s.strip_ansi.length }
|
|
264
265
|
chars, join, indented = 0, 1, (indent || '').length
|
|
265
266
|
narrow = width - indented
|
data/lib/rhc/output_helpers.rb
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
module RHC
|
|
2
2
|
module OutputHelpers
|
|
3
3
|
|
|
4
|
+
def display_domain(domain, applications=nil)
|
|
5
|
+
paragraph do
|
|
6
|
+
header ["Domain #{domain.id}", ("(owned by #{domain.owner})" if domain.owner.present?)] do
|
|
7
|
+
section(:bottom => 1) do
|
|
8
|
+
say format_table \
|
|
9
|
+
nil,
|
|
10
|
+
get_properties(
|
|
11
|
+
domain,
|
|
12
|
+
:creation_time,
|
|
13
|
+
:allowed_gear_sizes
|
|
14
|
+
),
|
|
15
|
+
:delete => true
|
|
16
|
+
end
|
|
17
|
+
applications.each do |a|
|
|
18
|
+
display_app(a,a.cartridges)
|
|
19
|
+
end if applications.present?
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
4
24
|
#---------------------------
|
|
5
25
|
# Application information
|
|
6
26
|
#---------------------------
|
|
@@ -12,6 +32,7 @@ module RHC
|
|
|
12
32
|
nil,
|
|
13
33
|
get_properties(
|
|
14
34
|
app,
|
|
35
|
+
:domain,
|
|
15
36
|
:creation_time,
|
|
16
37
|
:gear_info,
|
|
17
38
|
:git_url,
|
data/lib/rhc/rest.rb
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
module RHC
|
|
2
2
|
module Rest
|
|
3
3
|
|
|
4
|
-
autoload :Base,
|
|
5
|
-
autoload :Attributes,
|
|
4
|
+
autoload :Base, 'rhc/rest/base'
|
|
5
|
+
autoload :Attributes, 'rhc/rest/attributes'
|
|
6
|
+
|
|
7
|
+
autoload :HTTPClient, 'rhc/rest/httpclient'
|
|
6
8
|
|
|
7
9
|
autoload :Api, 'rhc/rest/api'
|
|
8
10
|
autoload :Application, 'rhc/rest/application'
|
data/lib/rhc/rest/api.rb
CHANGED
|
@@ -10,18 +10,20 @@ module RHC
|
|
|
10
10
|
@server_api_versions = []
|
|
11
11
|
debug "Client supports API versions #{preferred_api_versions.join(', ')}"
|
|
12
12
|
@client_api_versions = preferred_api_versions
|
|
13
|
-
@server_api_versions, links = api_info({
|
|
13
|
+
@server_api_versions, @current_api_version, links = api_info({
|
|
14
14
|
:url => client.url,
|
|
15
15
|
:method => :get,
|
|
16
|
+
:accept => :json,
|
|
16
17
|
:lazy_auth => true,
|
|
17
18
|
})
|
|
18
19
|
debug "Server supports API versions #{@server_api_versions.join(', ')}"
|
|
19
20
|
|
|
20
21
|
if api_version_negotiated
|
|
21
|
-
|
|
22
|
+
debug " Using API version #{api_version_negotiated}"
|
|
23
|
+
unless client_api_version_current?
|
|
22
24
|
debug "Client API version #{api_version_negotiated} is not current. Refetching API"
|
|
23
25
|
# need to re-fetch API
|
|
24
|
-
@server_api_versions, links = api_info({
|
|
26
|
+
@server_api_versions, @current_api_version, links = api_info({
|
|
25
27
|
:url => client.url,
|
|
26
28
|
:method => :get,
|
|
27
29
|
:accept => :json,
|
|
@@ -54,15 +56,11 @@ module RHC
|
|
|
54
56
|
end
|
|
55
57
|
|
|
56
58
|
def client_api_version_current?
|
|
57
|
-
|
|
59
|
+
current_api_version == api_version_negotiated
|
|
58
60
|
end
|
|
59
61
|
|
|
60
|
-
def
|
|
61
|
-
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def server_api_version_current?
|
|
65
|
-
@server_api_versions && @server_api_versions.max == api_version_negotiated
|
|
62
|
+
def current_api_version
|
|
63
|
+
@current_api_version
|
|
66
64
|
end
|
|
67
65
|
|
|
68
66
|
def warn_about_api_versions
|
|
@@ -81,7 +79,7 @@ server at #{URI.parse(client.url).host} supports #{@server_api_versions.join(',
|
|
|
81
79
|
def api_info(req)
|
|
82
80
|
client.request(req) do |response|
|
|
83
81
|
json_response = ::RHC::Json.decode(response.content)
|
|
84
|
-
[ json_response['supported_api_versions'], json_response['data'] ]
|
|
82
|
+
[ json_response['supported_api_versions'], json_response['api_version'] || json_response['version'].to_f, json_response['data'] ]
|
|
85
83
|
end
|
|
86
84
|
end
|
|
87
85
|
end
|