vas 0.3.0

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.
Files changed (87) hide show
  1. data/LICENSE +174 -0
  2. data/NOTICE +5 -0
  3. data/README.md +26 -0
  4. data/Rakefile +20 -0
  5. data/lib/vas.rb +103 -0
  6. data/lib/vas/gemfire/agent_configuration.rb +28 -0
  7. data/lib/vas/gemfire/agent_instances.rb +49 -0
  8. data/lib/vas/gemfire/agent_live_configurations.rb +29 -0
  9. data/lib/vas/gemfire/agent_logs.rb +38 -0
  10. data/lib/vas/gemfire/agent_node_instances.rb +38 -0
  11. data/lib/vas/gemfire/agent_pending_configurations.rb +38 -0
  12. data/lib/vas/gemfire/application_code.rb +54 -0
  13. data/lib/vas/gemfire/application_code_images.rb +76 -0
  14. data/lib/vas/gemfire/cache_server_configuration.rb +28 -0
  15. data/lib/vas/gemfire/cache_server_instances.rb +57 -0
  16. data/lib/vas/gemfire/cache_server_live_configurations.rb +29 -0
  17. data/lib/vas/gemfire/cache_server_logs.rb +38 -0
  18. data/lib/vas/gemfire/cache_server_node_instances.rb +46 -0
  19. data/lib/vas/gemfire/cache_server_pending_configurations.rb +38 -0
  20. data/lib/vas/gemfire/disk_stores.rb +63 -0
  21. data/lib/vas/gemfire/gemfire.rb +47 -0
  22. data/lib/vas/gemfire/groups.rb +50 -0
  23. data/lib/vas/gemfire/installation_images.rb +38 -0
  24. data/lib/vas/gemfire/installations.rb +53 -0
  25. data/lib/vas/gemfire/live_application_codes.rb +29 -0
  26. data/lib/vas/gemfire/locator_configuration.rb +28 -0
  27. data/lib/vas/gemfire/locator_instances.rb +109 -0
  28. data/lib/vas/gemfire/locator_live_configurations.rb +29 -0
  29. data/lib/vas/gemfire/locator_logs.rb +38 -0
  30. data/lib/vas/gemfire/locator_node_instances.rb +53 -0
  31. data/lib/vas/gemfire/locator_pending_configurations.rb +38 -0
  32. data/lib/vas/gemfire/nodes.rb +61 -0
  33. data/lib/vas/gemfire/pending_application_codes.rb +34 -0
  34. data/lib/vas/gemfire/statistics.rb +66 -0
  35. data/lib/vas/rabbitmq/configuration.rb +28 -0
  36. data/lib/vas/rabbitmq/groups.rb +42 -0
  37. data/lib/vas/rabbitmq/installation_images.rb +38 -0
  38. data/lib/vas/rabbitmq/installations.rb +43 -0
  39. data/lib/vas/rabbitmq/instances.rb +53 -0
  40. data/lib/vas/rabbitmq/live_configurations.rb +29 -0
  41. data/lib/vas/rabbitmq/logs.rb +38 -0
  42. data/lib/vas/rabbitmq/node_instances.rb +38 -0
  43. data/lib/vas/rabbitmq/nodes.rb +50 -0
  44. data/lib/vas/rabbitmq/pending_configurations.rb +38 -0
  45. data/lib/vas/rabbitmq/plugin_images.rb +67 -0
  46. data/lib/vas/rabbitmq/plugins.rb +85 -0
  47. data/lib/vas/rabbitmq/rabbitmq.rb +45 -0
  48. data/lib/vas/shared/collection.rb +46 -0
  49. data/lib/vas/shared/configuration.rb +59 -0
  50. data/lib/vas/shared/groups.rb +74 -0
  51. data/lib/vas/shared/installation_images.rb +62 -0
  52. data/lib/vas/shared/installations.rb +67 -0
  53. data/lib/vas/shared/instances.rb +74 -0
  54. data/lib/vas/shared/logs.rb +89 -0
  55. data/lib/vas/shared/mutable_collection.rb +27 -0
  56. data/lib/vas/shared/node_instances.rb +58 -0
  57. data/lib/vas/shared/nodes.rb +70 -0
  58. data/lib/vas/shared/pending_configuration.rb +40 -0
  59. data/lib/vas/shared/resource.rb +44 -0
  60. data/lib/vas/shared/security.rb +51 -0
  61. data/lib/vas/shared/state_resource.rb +44 -0
  62. data/lib/vas/tc_server/applications.rb +89 -0
  63. data/lib/vas/tc_server/configuration.rb +29 -0
  64. data/lib/vas/tc_server/groups.rb +42 -0
  65. data/lib/vas/tc_server/installation_images.rb +38 -0
  66. data/lib/vas/tc_server/installations.rb +54 -0
  67. data/lib/vas/tc_server/instances.rb +102 -0
  68. data/lib/vas/tc_server/live_configurations.rb +29 -0
  69. data/lib/vas/tc_server/logs.rb +38 -0
  70. data/lib/vas/tc_server/node_applications.rb +76 -0
  71. data/lib/vas/tc_server/node_instances.rb +55 -0
  72. data/lib/vas/tc_server/node_revisions.rb +55 -0
  73. data/lib/vas/tc_server/nodes.rb +50 -0
  74. data/lib/vas/tc_server/pending_configurations.rb +38 -0
  75. data/lib/vas/tc_server/revision_images.rb +67 -0
  76. data/lib/vas/tc_server/revisions.rb +71 -0
  77. data/lib/vas/tc_server/tc_server.rb +50 -0
  78. data/lib/vas/tc_server/template_images.rb +67 -0
  79. data/lib/vas/tc_server/templates.rb +70 -0
  80. data/lib/vas/util/client.rb +159 -0
  81. data/lib/vas/util/link_utils.rb +43 -0
  82. data/lib/vas/vas_exception.rb +32 -0
  83. data/lib/vas/vfabric/agent_image.rb +50 -0
  84. data/lib/vas/vfabric/nodes.rb +47 -0
  85. data/lib/vas/vfabric/v_fabric.rb +34 -0
  86. data/lib/vas/vfabric_administration_server.rb +50 -0
  87. metadata +213 -0
@@ -0,0 +1,50 @@
1
+ #--
2
+ # vFabric Administration Server Ruby API
3
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ module TcServer
19
+
20
+ # Used to enumerate tc Server nodes
21
+ class Nodes < Shared::Collection
22
+
23
+ def initialize(location, client) #:nodoc:
24
+ super(location, client, "nodes", Node)
25
+ end
26
+
27
+ end
28
+
29
+ # A tc Server node
30
+ class Node < Shared::GroupableNode
31
+
32
+ # The Node's Java home
33
+ attr_reader :java_home
34
+
35
+ def initialize(location, client) #:nodoc:
36
+ super(location, client, Group)
37
+ @java_home = details["java-home"]
38
+ end
39
+
40
+ def instances
41
+ @instances = NodeInstances.new(Util::LinkUtils.get_link_href(details, "node-instances"), client)
42
+ end
43
+
44
+ def to_s #:nodoc:
45
+ "#<#{self.class} host_names='#{host_names}' ip_addresses='#{ip_addresses}' operating_system='#{operating_system}' architecture='#{architecture}' agent_home='#{agent_home}' java_home='#{java_home}' metadata='#{metadata}'>"
46
+ end
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,38 @@
1
+ #--
2
+ # vFabric Administration Server Ruby API
3
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ module TcServer
19
+
20
+ # Used to enumerate an instance's pending configuration
21
+ class PendingConfigurations < Shared::PendingConfigurations
22
+
23
+ def initialize(location, client) #:nodoc:
24
+ super(location, client, 'pending-configurations', PendingConfiguration)
25
+ end
26
+
27
+ end
28
+
29
+ # A configuration file that is pending
30
+ class PendingConfiguration < Shared::PendingConfiguration
31
+
32
+ def initialize(location, client) #:nodoc:
33
+ super(location, client, 'group-instance', Instance)
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,67 @@
1
+ #--
2
+ # vFabric Administration Server Ruby API
3
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ module TcServer
19
+
20
+ # Used to enumerate, create, and delete tc Server revision images.
21
+ class RevisionImages < Shared::MutableCollection
22
+
23
+ def initialize(location, client) #:nodoc:
24
+ super(location, client, "revision-images", RevisionImage)
25
+ end
26
+
27
+ # Creates a RevisionImage named +name+ with the version +version+ by uploading the WAR file at the given +path+
28
+ def create(path, name, version)
29
+ RevisionImage.new(client.post_image(location, path, { :name => name, :version => version }), client)
30
+ end
31
+
32
+ end
33
+
34
+ # A revision image, i.e. a WAR file
35
+ class RevisionImage < Shared::Resource
36
+
37
+ # The revision image's name
38
+ attr_reader :name
39
+
40
+ # The revision image's version
41
+ attr_reader :version
42
+
43
+ # The revision image's size
44
+ attr_reader :size
45
+
46
+ def initialize(location, client) #:nodoc:
47
+ super(location, client)
48
+
49
+ @name = details["name"]
50
+ @version = details["version"]
51
+ @size = details['size']
52
+ end
53
+
54
+ # The revisions that have been created from this revision image
55
+ def revisions
56
+ revisions = []
57
+ Util::LinkUtils.get_link_hrefs(client.get(location), "group-revision").each { |revision_location| revisions << Revision.new(revision_location, client)}
58
+ revisions
59
+ end
60
+
61
+ def to_s #:nodoc:
62
+ "#<#{self.class} name='#@name' version='#@version'>"
63
+ end
64
+
65
+ end
66
+
67
+ end
@@ -0,0 +1,71 @@
1
+ #--
2
+ # vFabric Administration Server Ruby API
3
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ module TcServer
19
+
20
+ # Used to enumerate, create, and delete application revisions.
21
+ class Revisions < Shared::MutableCollection
22
+
23
+ def initialize(location, client) #:nodoc:
24
+ super(location, client, "revisions", Revision)
25
+ end
26
+
27
+ # Creates a Revision by deploying the RevisionImage +revision_image+
28
+ def create(revision_image)
29
+ Revision.new(client.post(location, { :image => revision_image.location}, 'group-revision'), client)
30
+ end
31
+
32
+ end
33
+
34
+ # A revision of an Application
35
+ class Revision < Shared::StateResource
36
+
37
+ # The Revision's version
38
+ attr_reader :version
39
+
40
+ # The Revision's application
41
+ attr_reader :application
42
+
43
+ def initialize(location, client) #:nodoc:
44
+ super(location, client)
45
+
46
+ @version = details['version']
47
+ @revision_image_location = Util::LinkUtils.get_link_href(details, 'revision-image')
48
+ @application = Application.new(Util::LinkUtils.get_link_href(details, 'group-application'), client)
49
+ end
50
+
51
+ # The revision image, if any, that was used to create the revision
52
+ def revision_image
53
+ if (!@revision_image_location.nil?)
54
+ RevisionImage.new(@revision_image_location, client)
55
+ end
56
+ end
57
+
58
+ # An array of the revision's individual node revisions
59
+ def node_revisions
60
+ node_revisions = []
61
+ Util::LinkUtils.get_link_hrefs(client.get(location), 'node-revision').each {
62
+ |node_revision_location| node_revisions << NodeRevision.new(node_revision_location, client)}
63
+ node_revisions
64
+ end
65
+
66
+ def to_s #:nodoc:
67
+ "#<#{self.class} version='#@version'>"
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,50 @@
1
+ #--
2
+ # vFabric Administration Server Ruby API
3
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ module TcServer
19
+
20
+ # The entry point to the API for administering tc Server
21
+ class TcServer
22
+
23
+ # The tc Server Groups
24
+ attr_reader :groups
25
+
26
+ # The tc Server InstallationImages
27
+ attr_reader :installation_images
28
+
29
+ # The tc Server Nodes
30
+ attr_reader :nodes
31
+
32
+ # The tc Server RevisionImages
33
+ attr_reader :revision_images
34
+
35
+ # The tc Server TemplateImages
36
+ attr_reader :template_images
37
+
38
+ def initialize(location, client) #:nodoc:
39
+
40
+ json = client.get(location)
41
+
42
+ @groups = Groups.new(Util::LinkUtils.get_link_href(json, "groups"), client)
43
+ @installation_images = InstallationImages.new(Util::LinkUtils.get_link_href(json, "installation-images"), client)
44
+ @nodes = Nodes.new(Util::LinkUtils.get_link_href(json, "nodes"), client)
45
+ @revision_images = RevisionImages.new(Util::LinkUtils.get_link_href(json, "revision-images"), client)
46
+ @template_images = TemplateImages.new(Util::LinkUtils.get_link_href(json, "template-images"), client)
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,67 @@
1
+ #--
2
+ # vFabric Administration Server Ruby API
3
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ module TcServer
19
+
20
+ # Used to enumerate, create, and delete tc Server template images.
21
+ class TemplateImages < Shared::MutableCollection
22
+
23
+ def initialize(location, client) #:nodoc:
24
+ super(location, client, "template-images", TemplateImage)
25
+ end
26
+
27
+ # Creates a TemplateImage named +name+ with the version +version+ by uploading the file at the given +path+
28
+ def create(path, name, version)
29
+ TemplateImage.new(client.post_image(location, path, { :name => name, :version => version }), client)
30
+ end
31
+
32
+ end
33
+
34
+ # A template image
35
+ class TemplateImage < Shared::Resource
36
+
37
+ # The template image's name
38
+ attr_reader :name
39
+
40
+ # The template image's version
41
+ attr_reader :version
42
+
43
+ # The template image's size
44
+ attr_reader :size
45
+
46
+ def initialize(location, client) #:nodoc:
47
+ super(location, client)
48
+
49
+ @name = details["name"]
50
+ @version = details["version"]
51
+ @size = details['size']
52
+ end
53
+
54
+ # The Template s that have been created from this TemplateImage
55
+ def templates
56
+ templates = []
57
+ Util::LinkUtils.get_link_hrefs(client.get(location), "template").each { |template_location| templates << Template.new(template_location, client)}
58
+ templates
59
+ end
60
+
61
+ def to_s #:nodoc:
62
+ "#<#{self.class} name='#@name' version='#@version'>"
63
+ end
64
+
65
+ end
66
+
67
+ end
@@ -0,0 +1,70 @@
1
+ #--
2
+ # vFabric Administration Server Ruby API
3
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ module TcServer
19
+
20
+ # Used to enumerate, create, and delete tc Server templates.
21
+ class Templates < Shared::MutableCollection
22
+
23
+ def initialize(location, client) #:nodoc:
24
+ super(location, client, "templates", Template)
25
+ end
26
+
27
+ # Creates a template from the +template_image+
28
+ def create(template_image)
29
+ Template.new(client.post(location, { :image => template_image.location }, "template"), client)
30
+ end
31
+
32
+ end
33
+
34
+ # A tc Server template
35
+ class Template < Shared::Resource
36
+
37
+ # The template's version
38
+ attr_reader :version
39
+
40
+ # The template's name
41
+ attr_reader :name
42
+
43
+ # The template image, if any, that this template was created from
44
+ attr_reader :template_image
45
+
46
+ # The template's installation
47
+ attr_reader :installation
48
+
49
+ def initialize(location, client) #:nodoc:
50
+ super(location, client)
51
+
52
+ @version = details["version"]
53
+ @name = details["name"]
54
+
55
+ template_image_location = Util::LinkUtils.get_link_href(details, "template-image")
56
+ if (!template_image_location.nil?)
57
+ @template_image = TemplateImage.new(template_image_location, client)
58
+ end
59
+
60
+ @installation = Installation.new(Util::LinkUtils.get_link_href(details, 'installation'), client)
61
+
62
+ end
63
+
64
+ def to_s #:nodoc:
65
+ "#<#{self.class} name='#@name' version='#@version'>"
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -0,0 +1,159 @@
1
+ #--
2
+ # vFabric Administration Server Ruby API
3
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ module Util #:nodoc: all
19
+
20
+ class Client
21
+
22
+ TASK_POLLING_INTERVAL = 1
23
+
24
+ def initialize(username, password)
25
+ @username = username
26
+ @password = password
27
+ end
28
+
29
+ def get(location)
30
+
31
+ req = Net::HTTP::Get.new(location)
32
+
33
+ do_request(req) { |res|
34
+ case res.code
35
+ when "200"
36
+ return JSON.parse(res.body)
37
+ else
38
+ raise_vas_exception(res)
39
+ end
40
+ }
41
+
42
+ end
43
+
44
+ def get_stream(location, &block)
45
+
46
+ req = Net::HTTP::Get.new(location)
47
+
48
+ do_request(req) { |res|
49
+ case res.code
50
+ when "200"
51
+ return res.read_body(&block)
52
+ else
53
+ raise_vas_exception(res)
54
+ end
55
+ }
56
+
57
+ end
58
+
59
+ def delete(location)
60
+ req = Net::HTTP::Delete.new(location)
61
+
62
+ do_request(req) { |res|
63
+ case res.code
64
+ when "200"
65
+ return
66
+ when "202"
67
+ await_task(res["Location"])
68
+ else
69
+ raise_vas_exception(res)
70
+ end
71
+ }
72
+ end
73
+
74
+ def post(location, payload, rel = nil)
75
+
76
+ req = Net::HTTP::Post.new(location)
77
+
78
+ req['Content-Type'] = "application/json"
79
+ req.body = payload.to_json
80
+
81
+ do_request(req) { |res|
82
+ case res.code
83
+ when "202"
84
+ return await_task(res["Location"], rel)
85
+ else
86
+ raise_vas_exception(res)
87
+ end
88
+ }
89
+ end
90
+
91
+ def post_image(location, path, metadata = nil)
92
+ File.open(path) { |image|
93
+ if (metadata.nil?)
94
+ req = Net::HTTP::Post::Multipart.new(location, :data => UploadIO.new(image, "application/octet-stream"))
95
+ elsif
96
+ req = Net::HTTP::Post::Multipart.new(location, :data => UploadIO.new(image, "application/octet-stream"), :metadata => UploadIO.new(StringIO.new(metadata.to_json), "application/json", "metadata.json"))
97
+ end
98
+
99
+ do_request(req) { |res|
100
+ case res.code
101
+ when "201"
102
+ return res["Location"]
103
+ else
104
+ raise_vas_exception(res)
105
+ end
106
+ }
107
+ }
108
+ end
109
+
110
+ private
111
+ def do_request(req)
112
+ req.basic_auth(@username, @password)
113
+
114
+ uri = URI(req.path)
115
+
116
+ https = Net::HTTP.new(uri.host, uri.port)
117
+ https.use_ssl = true
118
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
119
+
120
+ https.start() { |https|
121
+ https.request(req) { |res|
122
+ yield res
123
+ }
124
+ }
125
+
126
+ end
127
+
128
+ def await_task(task_location, rel = nil)
129
+ while true
130
+ task = get(task_location)
131
+ case task["status"]
132
+ when "PENDING"
133
+ when "IN_PROGRESS"
134
+ sleep TASK_POLLING_INTERVAL
135
+ when "SUCCESS"
136
+ if rel
137
+ return LinkUtils.get_link_hrefs(task, rel)[0]
138
+ else
139
+ return
140
+ end
141
+ else
142
+ raise VasException.new([task["message"], task["detail"]])
143
+ end
144
+ end
145
+ end
146
+
147
+ def raise_vas_exception(res)
148
+ messages = []
149
+ begin
150
+ json = JSON.parse(res.body)
151
+ json["reasons"].each { |reason| messages << reason["message"]}
152
+ ensure
153
+ raise VasException.new(messages, res.code)
154
+ end
155
+ end
156
+
157
+ end
158
+
159
+ end