fog 1.12.1 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/.travis.yml +1 -1
  2. data/Gemfile +5 -0
  3. data/Rakefile +14 -4
  4. data/bin/fog +22 -0
  5. data/changelog.txt +262 -0
  6. data/fog.gemspec +8 -4
  7. data/lib/fog/aws.rb +11 -0
  8. data/lib/fog/aws/auto_scaling.rb +15 -18
  9. data/lib/fog/aws/beanstalk.rb +8 -10
  10. data/lib/fog/aws/cloud_formation.rb +9 -12
  11. data/lib/fog/aws/compute.rb +8 -10
  12. data/lib/fog/aws/credential_fetcher.rb +6 -6
  13. data/lib/fog/aws/elasticache.rb +13 -17
  14. data/lib/fog/aws/elb.rb +29 -31
  15. data/lib/fog/aws/iam.rb +10 -13
  16. data/lib/fog/aws/models/auto_scaling/group.rb +6 -3
  17. data/lib/fog/aws/models/compute/spot_request.rb +1 -11
  18. data/lib/fog/aws/models/rds/log_file.rb +26 -0
  19. data/lib/fog/aws/models/rds/log_files.rb +50 -0
  20. data/lib/fog/aws/models/rds/server.rb +3 -1
  21. data/lib/fog/aws/models/rds/snapshot.rb +1 -0
  22. data/lib/fog/aws/models/rds/snapshots.rb +20 -13
  23. data/lib/fog/aws/parsers/rds/db_parser.rb +1 -1
  24. data/lib/fog/aws/parsers/rds/describe_db_log_files.rb +44 -0
  25. data/lib/fog/aws/parsers/rds/download_db_logfile_portion.rb +26 -0
  26. data/lib/fog/aws/parsers/ses/verify_domain_identity.rb +26 -0
  27. data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +1 -1
  28. data/lib/fog/aws/parsers/sts/assume_role.rb +30 -0
  29. data/lib/fog/aws/rds.rb +27 -14
  30. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
  31. data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +8 -1
  32. data/lib/fog/aws/requests/compute/create_volume.rb +3 -3
  33. data/lib/fog/aws/requests/rds/create_db_instance.rb +3 -1
  34. data/lib/fog/aws/requests/rds/describe_db_log_files.rb +67 -0
  35. data/lib/fog/aws/requests/rds/download_db_logfile_portion.rb +63 -0
  36. data/lib/fog/aws/requests/ses/send_raw_email.rb +1 -1
  37. data/lib/fog/aws/requests/ses/verify_domain_identity.rb +30 -0
  38. data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +6 -2
  39. data/lib/fog/aws/requests/storage/get_object.rb +1 -1
  40. data/lib/fog/aws/requests/sts/assume_role.rb +46 -0
  41. data/lib/fog/aws/ses.rb +26 -9
  42. data/lib/fog/aws/storage.rb +2 -1
  43. data/lib/fog/aws/sts.rb +31 -21
  44. data/lib/fog/bin.rb +0 -1
  45. data/lib/fog/bin/openstack.rb +5 -0
  46. data/lib/fog/brightbox/compute.rb +20 -212
  47. data/lib/fog/brightbox/compute/shared.rb +232 -0
  48. data/lib/fog/brightbox/models/compute/collaboration.rb +43 -0
  49. data/lib/fog/brightbox/models/compute/collaborations.rb +23 -0
  50. data/lib/fog/brightbox/models/compute/user_collaboration.rb +29 -0
  51. data/lib/fog/brightbox/models/compute/user_collaborations.rb +23 -0
  52. data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +21 -0
  53. data/lib/fog/brightbox/requests/compute/create_collaboration.rb +23 -0
  54. data/lib/fog/brightbox/requests/compute/delete_collaboration.rb +28 -0
  55. data/lib/fog/brightbox/requests/compute/delete_user_collaboration.rb +28 -0
  56. data/lib/fog/brightbox/requests/compute/destroy_user_collaboration.rb +21 -0
  57. data/lib/fog/brightbox/requests/compute/get_collaboration.rb +21 -0
  58. data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +21 -0
  59. data/lib/fog/brightbox/requests/compute/list_collaborations.rb +19 -0
  60. data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +19 -0
  61. data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +21 -0
  62. data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +21 -0
  63. data/lib/fog/cloudsigma/docs/getting_started.md +59 -0
  64. data/lib/fog/core.rb +7 -2
  65. data/lib/fog/core/connection.rb +62 -29
  66. data/lib/fog/core/deprecated/connection.rb +24 -0
  67. data/lib/fog/core/parser.rb +1 -1
  68. data/lib/fog/digitalocean/examples/getting_started.md +1 -1
  69. data/lib/fog/digitalocean/models/compute/server.rb +2 -2
  70. data/lib/fog/google/compute.rb +31 -7
  71. data/lib/fog/google/models/compute/disk.rb +80 -0
  72. data/lib/fog/google/models/compute/disks.rb +28 -0
  73. data/lib/fog/google/models/compute/image.rb +36 -0
  74. data/lib/fog/google/models/compute/server.rb +46 -33
  75. data/lib/fog/google/models/compute/servers.rb +15 -8
  76. data/lib/fog/google/requests/compute/delete_server.rb +5 -2
  77. data/lib/fog/google/requests/compute/get_disk.rb +3 -0
  78. data/lib/fog/google/requests/compute/get_server.rb +7 -1
  79. data/lib/fog/google/requests/compute/insert_disk.rb +8 -2
  80. data/lib/fog/google/requests/compute/insert_server.rb +51 -22
  81. data/lib/fog/google/requests/compute/list_machine_types.rb +3 -2
  82. data/lib/fog/google/requests/storage/get_object.rb +1 -1
  83. data/lib/fog/hp/requests/storage/get_object.rb +1 -1
  84. data/lib/fog/hp/storage.rb +26 -9
  85. data/lib/fog/ibm/requests/compute/create_instance.rb +20 -15
  86. data/lib/fog/internet_archive/requests/storage/get_object.rb +1 -1
  87. data/lib/fog/{core/json.rb → json.rb} +13 -2
  88. data/lib/fog/metering.rb +25 -0
  89. data/lib/fog/openstack.rb +1 -0
  90. data/lib/fog/openstack/metering.rb +215 -0
  91. data/lib/fog/openstack/models/compute/flavors.rb +2 -2
  92. data/lib/fog/openstack/models/compute/metadata.rb +1 -1
  93. data/lib/fog/openstack/models/compute/server.rb +5 -2
  94. data/lib/fog/openstack/models/image/images.rb +1 -1
  95. data/lib/fog/openstack/models/metering/meter.rb +0 -0
  96. data/lib/fog/openstack/models/metering/meters.rb +0 -0
  97. data/lib/fog/openstack/models/metering/resource.rb +24 -0
  98. data/lib/fog/openstack/models/metering/resources.rb +25 -0
  99. data/lib/fog/openstack/models/volume/volume.rb +3 -1
  100. data/lib/fog/openstack/models/volume/volumes.rb +2 -1
  101. data/lib/fog/openstack/network.rb +1 -1
  102. data/lib/fog/openstack/requests/compute/create_flavor.rb +1 -1
  103. data/lib/fog/openstack/requests/compute/create_server.rb +19 -1
  104. data/lib/fog/openstack/requests/compute/detach_volume.rb +2 -1
  105. data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +4 -3
  106. data/lib/fog/openstack/requests/compute/list_security_groups.rb +1 -1
  107. data/lib/fog/openstack/requests/identity/create_tenant.rb +2 -2
  108. data/lib/fog/openstack/requests/metering/get_resource.rb +32 -0
  109. data/lib/fog/openstack/requests/metering/get_samples.rb +55 -0
  110. data/lib/fog/openstack/requests/metering/get_statistics.rb +56 -0
  111. data/lib/fog/openstack/requests/metering/list_meters.rb +50 -0
  112. data/lib/fog/openstack/requests/metering/list_resources.rb +32 -0
  113. data/lib/fog/openstack/requests/volume/create_volume.rb +4 -2
  114. data/lib/fog/rackspace.rb +16 -1
  115. data/lib/fog/rackspace/block_storage.rb +13 -28
  116. data/lib/fog/rackspace/cdn.rb +10 -24
  117. data/lib/fog/rackspace/compute.rb +17 -45
  118. data/lib/fog/rackspace/compute_v2.rb +13 -33
  119. data/lib/fog/rackspace/databases.rb +13 -29
  120. data/lib/fog/rackspace/dns.rb +27 -23
  121. data/lib/fog/rackspace/identity.rb +10 -26
  122. data/lib/fog/rackspace/load_balancers.rb +13 -29
  123. data/lib/fog/rackspace/mock_data.rb +3 -3
  124. data/lib/fog/rackspace/models/compute/server.rb +1 -1
  125. data/lib/fog/rackspace/models/dns/zones.rb +34 -21
  126. data/lib/fog/rackspace/models/identity/users.rb +2 -2
  127. data/lib/fog/rackspace/models/storage/file.rb +1 -0
  128. data/lib/fog/rackspace/requests/dns/list_domains.rb +2 -2
  129. data/lib/fog/rackspace/requests/storage/delete_multiple_objects.rb +75 -0
  130. data/lib/fog/rackspace/requests/storage/delete_static_large_object.rb +50 -0
  131. data/lib/fog/rackspace/requests/storage/get_object.rb +3 -1
  132. data/lib/fog/rackspace/requests/storage/put_dynamic_obj_manifest.rb +44 -0
  133. data/lib/fog/rackspace/requests/storage/put_object_manifest.rb +3 -30
  134. data/lib/fog/rackspace/requests/storage/put_static_obj_manifest.rb +60 -0
  135. data/lib/fog/rackspace/service.rb +43 -1
  136. data/lib/fog/rackspace/storage.rb +25 -43
  137. data/lib/fog/riakcs/provisioning.rb +2 -1
  138. data/lib/fog/riakcs/usage.rb +2 -1
  139. data/lib/fog/vcloud/requests/compute/configure_vm_cpus.rb +1 -1
  140. data/lib/fog/vcloud/requests/compute/configure_vm_memory.rb +1 -1
  141. data/lib/fog/version.rb +1 -1
  142. data/lib/fog/vsphere/requests/compute/get_folder.rb +1 -1
  143. data/lib/fog/xenserver/compute.rb +2 -0
  144. data/lib/fog/xenserver/models/compute/server.rb +9 -7
  145. data/lib/fog/xenserver/requests/compute/snapshot_revert.rb +22 -0
  146. data/lib/fog/xenserver/requests/compute/snapshot_server.rb +22 -0
  147. data/lib/fog/xml.rb +21 -0
  148. data/lib/fog/xml/sax_parser_connection.rb +43 -0
  149. data/lib/tasks/changelog_task.rb +1 -0
  150. data/tests/aws/models/auto_scaling/groups_test.rb +22 -0
  151. data/tests/aws/requests/compute/volume_tests.rb +3 -3
  152. data/tests/aws/requests/rds/helper.rb +14 -0
  153. data/tests/aws/requests/rds/log_file_tests.rb +19 -0
  154. data/tests/aws/requests/ses/verified_domain_identity_tests.rb +16 -0
  155. data/tests/aws/requests/sts/assume_role_tests.rb +19 -0
  156. data/tests/brightbox/requests/compute/collaboration_tests.rb +41 -0
  157. data/tests/brightbox/requests/compute/helper.rb +46 -2
  158. data/tests/brightbox/requests/compute/user_collaboration_tests.rb +67 -0
  159. data/tests/core/connection_tests.rb +26 -0
  160. data/tests/helper.rb +13 -0
  161. data/tests/openstack/requests/metering/meter_tests.rb +52 -0
  162. data/tests/openstack/requests/metering/resource_tests.rb +19 -0
  163. data/tests/openvz/helper.rb +14 -8
  164. data/tests/rackspace/block_storage_tests.rb +9 -0
  165. data/tests/rackspace/compute_tests.rb +9 -0
  166. data/tests/rackspace/compute_v2_tests.rb +9 -0
  167. data/tests/rackspace/databases_tests.rb +9 -0
  168. data/tests/rackspace/dns_tests.rb +20 -0
  169. data/tests/rackspace/helper.rb +12 -1
  170. data/tests/rackspace/identity_tests.rb +25 -0
  171. data/tests/rackspace/load_balancer_tests.rb +10 -0
  172. data/tests/rackspace/models/block_storage/volume_tests.rb +2 -2
  173. data/tests/rackspace/models/compute_v2/metadata_tests.rb +2 -2
  174. data/tests/rackspace/models/compute_v2/server_tests.rb +22 -21
  175. data/tests/rackspace/models/dns/zones_tests.rb +19 -5
  176. data/tests/rackspace/models/storage/file_tests.rb +22 -6
  177. data/tests/rackspace/rackspace_tests.rb +35 -0
  178. data/tests/rackspace/requests/block_storage/snapshot_tests.rb +2 -3
  179. data/tests/rackspace/requests/block_storage/volume_type_tests.rb +4 -11
  180. data/tests/rackspace/requests/compute_v2/address_tests.rb +1 -1
  181. data/tests/rackspace/requests/compute_v2/attachment_tests.rb +8 -9
  182. data/tests/rackspace/requests/compute_v2/flavor_tests.rb +1 -1
  183. data/tests/rackspace/requests/compute_v2/metadata_tests.rb +4 -4
  184. data/tests/rackspace/requests/databases/database_tests.rb +23 -20
  185. data/tests/rackspace/requests/databases/user_tests.rb +6 -6
  186. data/tests/rackspace/requests/identity/user_tests.rb +4 -1
  187. data/tests/rackspace/requests/load_balancers/usage_tests.rb +4 -2
  188. data/tests/rackspace/requests/storage/large_object_tests.rb +303 -59
  189. data/tests/rackspace/requests/storage/object_tests.rb +73 -18
  190. data/tests/rackspace/service_tests.rb +83 -0
  191. data/tests/rackspace/storage_tests.rb +9 -0
  192. data/tests/xenserver/models/compute/server_tests.rb +11 -1
  193. metadata +89 -19
  194. data/tests/core/user_agent_tests.rb +0 -6
@@ -0,0 +1,232 @@
1
+ require "fog/brightbox/oauth2"
2
+
3
+ module Fog
4
+ module Brightbox
5
+ module Compute
6
+
7
+ # The Shared module consists of code that was duplicated between the Real
8
+ # and Mock implementations.
9
+ #
10
+ module Shared
11
+ include Fog::Brightbox::OAuth2
12
+
13
+ API_URL = "https://api.gb1.brightbox.com/"
14
+
15
+ # Creates a new instance of the Brightbox Compute service
16
+ #
17
+ # @note If you create service using just a refresh token when it
18
+ # expires the service will no longer be able to authenticate.
19
+ #
20
+ # @param [Hash] options
21
+ # @option options [String] :brightbox_api_url
22
+ # Override the default (or configured) API endpoint
23
+ # @option options [String] :brightbox_auth_url
24
+ # Override the default (or configured) API authentication endpoint
25
+ # @option options [String] :brightbox_client_id
26
+ # Client identifier to authenticate with (overrides configured)
27
+ # @option options [String] :brightbox_secret
28
+ # Client secret to authenticate with (overrides configured)
29
+ # @option options [String] :brightbox_username
30
+ # Email or user identifier for user based authentication
31
+ # @option options [String] :brightbox_password
32
+ # Password for user based authentication
33
+ # @option options [String] :brightbox_account
34
+ # Account identifier to scope this connection to
35
+ # @option options [String] :connection_options
36
+ # Settings to pass to underlying {Fog::Connection}
37
+ # @option options [Boolean] :persistent
38
+ # Sets a persistent HTTP {Fog::Connection}
39
+ # @option options [String] :brightbox_access_token
40
+ # Sets the OAuth access token to use rather than requesting a new token
41
+ # @option options [String] :brightbox_refresh_token
42
+ # Sets the refresh token to use when requesting a newer access token
43
+ # @option options [String] (true) :brightbox_token_management
44
+ # Overide the existing behaviour to request access tokens if expired
45
+ #
46
+ def initialize(options)
47
+ # Currently authentication and api endpoints are the same but may change
48
+ @auth_url = options[:brightbox_auth_url] || Fog.credentials[:brightbox_auth_url] || API_URL
49
+ @auth_connection = Fog::Connection.new(@auth_url)
50
+
51
+ @api_url = options[:brightbox_api_url] || Fog.credentials[:brightbox_api_url] || API_URL
52
+ @connection_options = options[:connection_options] || {}
53
+ @persistent = options[:persistent] || false
54
+ @connection = Fog::Connection.new(@api_url, @persistent, @connection_options)
55
+
56
+ # Authentication options
57
+ client_id = options[:brightbox_client_id] || Fog.credentials[:brightbox_client_id]
58
+ client_secret = options[:brightbox_secret] || Fog.credentials[:brightbox_secret]
59
+
60
+ username = options[:brightbox_username] || Fog.credentials[:brightbox_username]
61
+ password = options[:brightbox_password] || Fog.credentials[:brightbox_password]
62
+ @configured_account = options[:brightbox_account] || Fog.credentials[:brightbox_account]
63
+ # Request account can be changed at anytime and changes behaviour of future requests
64
+ @scoped_account = @configured_account
65
+
66
+ credential_options = {:username => username, :password => password}
67
+ @credentials = CredentialSet.new(client_id, client_secret, credential_options)
68
+
69
+ # If existing tokens have been cached, allow continued use of them in the service
70
+ @credentials.update_tokens(options[:brightbox_access_token], options[:brightbox_refresh_token])
71
+
72
+ @token_management = options.fetch(:brightbox_token_management, true)
73
+ end
74
+
75
+ # Sets the scoped account for future requests
76
+ # @param [String] scoped_account Identifier of the account to scope request to
77
+ def scoped_account=(scoped_account)
78
+ @scoped_account = scoped_account
79
+ end
80
+
81
+ # This returns the account identifier that the request should be scoped by
82
+ # based on the options passed to the request and current configuration
83
+ #
84
+ # @param [String] options_account Any identifier passed into the request
85
+ #
86
+ # @return [String, nil] The account identifier to scope the request to or nil
87
+ def scoped_account(options_account = nil)
88
+ [options_account, @scoped_account].compact.first
89
+ end
90
+
91
+ # Resets the scoped account back to intially configured one
92
+ def scoped_account_reset
93
+ @scoped_account = @configured_account
94
+ end
95
+
96
+ # Returns the scoped account being used for requests
97
+ #
98
+ # * For API clients this is the owning account
99
+ # * For User applications this is the account specified by either +account_id+
100
+ # option on the service or the +brightbox_account+ setting in your configuration
101
+ #
102
+ # @return [Fog::Compute::Brightbox::Account]
103
+ #
104
+ def account
105
+ account_data = get_scoped_account.merge(:service => self)
106
+ Fog::Compute::Brightbox::Account.new(account_data)
107
+ end
108
+
109
+ # Returns true if authentication is being performed as a user
110
+ # @return [Boolean]
111
+ def authenticating_as_user?
112
+ @credentials.user_details?
113
+ end
114
+
115
+ # Returns true if an access token is set
116
+ # @return [Boolean]
117
+ def access_token_available?
118
+ !! @credentials.access_token
119
+ end
120
+
121
+ # Returns the current access token or nil
122
+ # @return [String,nil]
123
+ def access_token
124
+ @credentials.access_token
125
+ end
126
+
127
+ # Returns the current refresh token or nil
128
+ # @return [String,nil]
129
+ def refresh_token
130
+ @credentials.refresh_token
131
+ end
132
+
133
+ # Returns the current token expiry time in seconds or nil
134
+ # @return [Number,nil]
135
+ def expires_in
136
+ @credentials.expires_in
137
+ end
138
+
139
+ # Requests a new access token
140
+ #
141
+ # @return [String] New access token
142
+ def get_access_token
143
+ begin
144
+ get_access_token!
145
+ rescue Excon::Errors::Unauthorized, Excon::Errors::BadRequest
146
+ @credentials.update_tokens(nil, nil)
147
+ end
148
+ @credentials.access_token
149
+ end
150
+
151
+ # Requests a new access token and raises if there is a problem
152
+ #
153
+ # @return [String] New access token
154
+ # @raise [Excon::Errors::BadRequest] The credentials are expired or incorrect
155
+ #
156
+ def get_access_token!
157
+ response = request_access_token(@auth_connection, @credentials)
158
+ update_credentials_from_response(@credentials, response)
159
+ @credentials.access_token
160
+ end
161
+
162
+ # Returns an identifier for the default image for use
163
+ #
164
+ # Currently tries to find the latest version of Ubuntu (i686) from
165
+ # Brightbox.
166
+ #
167
+ # Highly recommended that you actually select the image you want to run
168
+ # on your servers yourself!
169
+ #
170
+ # @return [String] if image is found, returns the identifier
171
+ # @return [NilClass] if no image is found or an error occurs
172
+ #
173
+ def default_image
174
+ return @default_image_id unless @default_image_id.nil?
175
+ @default_image_id = Fog.credentials[:brightbox_default_image] || select_default_image
176
+ end
177
+
178
+ private
179
+
180
+ # This makes a request of the API based on the configured setting for
181
+ # token management.
182
+ #
183
+ # @param [Hash] options Excon compatible options
184
+ # @see https://github.com/geemus/excon/blob/master/lib/excon/connection.rb
185
+ #
186
+ # @return [Hash] Data of response body
187
+ #
188
+ def make_request(options)
189
+ if @token_management
190
+ managed_token_request(options)
191
+ else
192
+ authenticated_request(options)
193
+ end
194
+ end
195
+
196
+ # This request checks for access tokens and will ask for a new one if
197
+ # it receives Unauthorized from the API before repeating the request
198
+ #
199
+ # @param [Hash] options Excon compatible options
200
+ #
201
+ # @return [Excon::Response]
202
+ def managed_token_request(options)
203
+ begin
204
+ get_access_token unless access_token_available?
205
+ response = authenticated_request(options)
206
+ rescue Excon::Errors::Unauthorized
207
+ get_access_token
208
+ response = authenticated_request(options)
209
+ end
210
+ end
211
+
212
+ # This request makes an authenticated request of the API using currently
213
+ # setup credentials.
214
+ #
215
+ # @param [Hash] options Excon compatible options
216
+ #
217
+ # @see https://github.com/geemus/excon/blob/master/lib/excon/connection.rb
218
+ #
219
+ # @return [Excon::Response]
220
+ def authenticated_request(options)
221
+ headers = options[:headers] || {}
222
+ headers.merge!("Authorization" => "OAuth #{@credentials.access_token}", "Content-Type" => "application/json")
223
+ options[:headers] = headers
224
+ # TODO This is just a wrapper around a call to Excon::Connection#request
225
+ # so can be extracted from Compute by passing in the connection,
226
+ # credentials and options
227
+ @connection.request(options)
228
+ end
229
+ end
230
+ end
231
+ end
232
+ end
@@ -0,0 +1,43 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Compute
5
+ class Brightbox
6
+ class Collaboration < Fog::Model
7
+ identity :id
8
+ attribute :status
9
+ attribute :email
10
+ attribute :role
11
+ attribute :role_label
12
+ attribute :account
13
+ attribute :user
14
+ attribute :inviter
15
+
16
+ def account_id
17
+ account['id'] || account[:id]
18
+ end
19
+
20
+ def save
21
+ raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
22
+
23
+ options = {
24
+ :role => role,
25
+ :email => email
26
+ }.delete_if { |k, v| v.nil? || v == "" }
27
+
28
+ data = connection.create_collaboration(options)
29
+ merge_attributes(data)
30
+ true
31
+ end
32
+
33
+ def destroy
34
+ requires :identity
35
+ connection.destroy_collaboration(identity)
36
+ true
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,23 @@
1
+ require "fog/core/collection"
2
+ require "fog/brightbox/models/compute/collaboration"
3
+
4
+ module Fog
5
+ module Compute
6
+ class Brightbox
7
+ class Collaborations < Fog::Collection
8
+ model Fog::Compute::Brightbox::Collaboration
9
+
10
+ def all
11
+ data = connection.list_collaborations
12
+ load(data)
13
+ end
14
+
15
+ def destroy
16
+ requires :identity
17
+ connection.destroy_collaboration(identity)
18
+ true
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Compute
5
+ class Brightbox
6
+ class UserCollaboration < Fog::Model
7
+ identity :id
8
+ attribute :status
9
+ attribute :email
10
+ attribute :role
11
+ attribute :role_label
12
+ attribute :account
13
+ attribute :user
14
+ attribute :inviter
15
+
16
+ def account_id
17
+ account['id'] || account[:id]
18
+ end
19
+
20
+ def destroy
21
+ requires :identity
22
+ connection.destroy_user_collaboration(identity)
23
+ true
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ require "fog/core/collection"
2
+ require "fog/brightbox/models/compute/user_collaboration"
3
+
4
+ module Fog
5
+ module Compute
6
+ class Brightbox
7
+ class UserCollaborations < Fog::Collection
8
+ model Fog::Compute::Brightbox::UserCollaboration
9
+
10
+ def all
11
+ data = connection.list_user_collaborations
12
+ load(data)
13
+ end
14
+
15
+ def destroy
16
+ requires :identity
17
+ connection.destroy_user_collaboration(identity)
18
+ true
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ module Fog
2
+ module Compute
3
+ class Brightbox
4
+ class Real
5
+ # Accepts the collaboration and gaining permitted access
6
+ #
7
+ # @param [String] identifier Unique reference to identify the resource
8
+ #
9
+ # @return [Hash] if successful Hash version of JSON object
10
+ #
11
+ # @see https://api.gb1.brightbox.com/1.0/#user_collaboration_accept_user_collaboration
12
+ #
13
+ def accept_user_collaboration(identifier)
14
+ return nil if identifier.nil? || identifier == ""
15
+ wrapped_request("post", "/1.0/user/collaborations/#{identifier}/accept", [200])
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module Compute
3
+ class Brightbox
4
+ class Real
5
+ # Creates a new collaboration for a user for the account
6
+ #
7
+ # @param [Hash] options
8
+ # @option options [String] :email Email address of user to invite
9
+ # @option options [String] :role Role to grant to the user. Currently only `admin`
10
+ #
11
+ # @return [Hash] if successful Hash version of JSON object
12
+ # @return [NilClass] if no options were passed
13
+ #
14
+ # @see https://api.gb1.brightbox.com/1.0/#collaboration_create_collaboration
15
+ #
16
+ def create_collaboration(options)
17
+ wrapped_request("post", "/1.0/collaborations", [201], options)
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Compute
3
+ class Brightbox
4
+ class Real
5
+ # Cancels or completes the collaboration
6
+ #
7
+ # @param [String] identifier Unique reference to identify the resource
8
+ #
9
+ # @return [Hash] if successful Hash version of JSON object
10
+ #
11
+ # @see https://api.gb1.brightbox.com/1.0/#collaboration_delete_collaboration
12
+ #
13
+ def delete_collaboration(identifier)
14
+ return nil if identifier.nil? || identifier == ""
15
+ wrapped_request("delete", "/1.0/collaborations/#{identifier}", [200])
16
+ end
17
+
18
+ # Old format of the delete request.
19
+ #
20
+ # @deprecated Use +#delete_collaboration+ instead
21
+ #
22
+ def destroy_collaboration(identifier)
23
+ delete_collaboration(identifier)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Compute
3
+ class Brightbox
4
+ class Real
5
+ # Ends an existing 'accepted' collaboration
6
+ #
7
+ # @param [String] identifier Unique reference to identify the resource
8
+ #
9
+ # @return [Hash] if successful Hash version of JSON object
10
+ #
11
+ # @see https://api.gb1.brightbox.com/1.0/#user_collaboration_delete_user_collaboration
12
+ #
13
+ def delete_user_collaboration(identifier)
14
+ return nil if identifier.nil? || identifier == ""
15
+ wrapped_request("delete", "/1.0/user/collaborations/#{identifier}", [200])
16
+ end
17
+
18
+ # Old format of the delete request.
19
+ #
20
+ # @deprecated Use +#delete_user_collaboration+ instead
21
+ #
22
+ def destroy_user_collaboration(identifier)
23
+ delete_user_collaboration(identifier)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end