fog-brightbox-0.7.1/0000755000004100000410000000000012464011624014310 5ustar www-datawww-datafog-brightbox-0.7.1/Rakefile0000644000004100000410000000026112464011624015754 0ustar www-datawww-datarequire "bundler/gem_tasks" require "rake/testtask" task :default => :test Rake::TestTask.new do |t| t.libs << "spec" t.pattern = File.join("spec", "**", "*_spec.rb") end fog-brightbox-0.7.1/Gemfile0000644000004100000410000000004712464011624015604 0ustar www-datawww-datasource "https://rubygems.org" gemspec fog-brightbox-0.7.1/.rubocop_todo.yml0000644000004100000410000000347712464011624017622 0ustar www-datawww-data# This configuration was generated by `rubocop --auto-gen-config` # on 2014-10-23 16:16:50 +0100 using RuboCop version 0.23.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 2 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: Enabled: false # Offense count: 4 Style/AccessorMethodName: Enabled: false # Offense count: 2 # Cop supports --auto-correct. Style/Blocks: Enabled: false # Offense count: 4 # Configuration parameters: CountComments. Style/ClassLength: Max: 165 # Offense count: 4 Style/CyclomaticComplexity: Max: 8 # Offense count: 190 Style/Documentation: Enabled: false # Offense count: 26 # Configuration parameters: EnforcedStyle, SupportedStyles. Style/DotPosition: Enabled: false # Offense count: 5 Style/DoubleNegation: Enabled: false # Offense count: 2 # Configuration parameters: MinBodyLength. Style/GuardClause: Enabled: false # Offense count: 1 # Configuration parameters: MaxLineLength. Style/IfUnlessModifier: Enabled: false # Offense count: 23 # Configuration parameters: CountComments. Style/MethodLength: Max: 24 # Offense count: 2 Style/MultilineBlockChain: Enabled: false # Offense count: 1 # Configuration parameters: EnforcedStyle, SupportedStyles. Style/Next: Enabled: false # Offense count: 9 # Configuration parameters: EnforcedStyle, SupportedStyles. Style/RaiseArgs: Enabled: false # Offense count: 3 Style/RegexpLiteral: MaxSlashes: 0 # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist. Style/TrivialAccessors: Enabled: false fog-brightbox-0.7.1/LICENSE.txt0000644000004100000410000000206712464011624016140 0ustar www-datawww-dataCopyright (c) 2014 Brightbox Systems Ltd. MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. fog-brightbox-0.7.1/spec/0000755000004100000410000000000012464011624015242 5ustar www-datawww-datafog-brightbox-0.7.1/spec/model_setup.rb0000644000004100000410000000122712464011624020111 0ustar www-datawww-datamodule ModelSetup def self.included(base) base.class_eval do let(:configuration) do { :brightbox_auth_url => "http://localhost", :brightbox_api_url => "http://localhost", :brightbox_client_id => "", :brightbox_secret => "", :brightbox_username => "", :brightbox_password => "", :brightbox_account => "", :brightbox_default_image => "img-test", :brightbox_access_token => "FAKECACHEDTOKEN" } end let(:config) { Fog::Brightbox::Config.new(configuration) } let(:service) { Fog::Compute::Brightbox.new(config) } end end end fog-brightbox-0.7.1/spec/stock_storage_responses.rb0000644000004100000410000000165312464011624022544 0ustar www-datawww-datamodule StockStorageResponses def authorized_response { :status => 200, :body => "Authenticated", :headers => { "X-Storage-Url" => "https://orbit.brightbox.com/v1/acc-12345", "X-Storage-Token" => "abcdefghijklmnopqrstuvwxyz1234567890", "X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890", "Content-Type" => "text/plain" } } end def unauthorized_response { :status => 401, :body => "

Unauthorized

This server could not verify that you are authorized to access the document you requested.

", :headers => { "Content-Length" => 131, "Content-Type" => "text/html; charset=UTF-8" } } end def bad_url_response { :status => 412, :body => "Bad URL", :headers => { "Content-Length" => 7, "Content-Type" => "text/html; charset=UTF-8" } } end end fog-brightbox-0.7.1/spec/spec_helper.rb0000644000004100000410000000021712464011624020060 0ustar www-datawww-datarequire "minitest/autorun" require "fog/brightbox" require "model_setup" require "supports_resource_locking" require "stock_storage_responses" fog-brightbox-0.7.1/spec/fog/0000755000004100000410000000000012464011624016015 5ustar www-datawww-datafog-brightbox-0.7.1/spec/fog/storage/0000755000004100000410000000000012464011624017461 5ustar www-datawww-datafog-brightbox-0.7.1/spec/fog/storage/brightbox_spec.rb0000644000004100000410000002337212464011624023017 0ustar www-datawww-datarequire "minitest/autorun" require "webmock/minitest" require "fog/brightbox" describe Fog::Storage::Brightbox do include StockStorageResponses let(:config) { Fog::Brightbox::Config.new(settings) } let(:service) { Fog::Storage::Brightbox.new(config) } describe "when created without required arguments" do it "raises an error" do Fog.stub :credentials, {} do assert_raises ArgumentError do Fog::Storage::Brightbox.new({}) end end end end describe "when created with a Config object" do let(:settings) do { :brightbox_client_id => "cli-12345", :brightbox_secret => "1234567890" } end it "does not error" do service pass end end describe "when created with Config missing required settings" do let(:settings) { {} } it "raises ArgumentError" do assert_raises ArgumentError do Fog::Storage::Brightbox.new(config) end end end describe "when created with a viable config" do let(:settings) do { :brightbox_client_id => "cli-12345", :brightbox_secret => "fdkls" } end before do stub_request(:get, "https://orbit.brightbox.com/v1"). to_return(authorized_response) end it "requires a call to authenticate" do assert service.needs_to_authenticate? end it "requires a call to discover management_url" do assert_nil service.management_url end it "can authenticate" do service.authenticate assert_equal "https://orbit.brightbox.com/v1/acc-12345", service.management_url.to_s end end describe "when created with bad credentials" do let(:settings) do { :brightbox_client_id => "cli-12345", :brightbox_secret => "wrong" } end it "fails to authenticate" do stub_request(:get, "https://orbit.brightbox.com/v1"). to_return(unauthorized_response) assert_raises(Fog::Brightbox::Storage::AuthenticationRequired) { service.authenticate } assert_nil service.management_url end end describe "when configured scoped to a specific account" do let(:settings) do { :brightbox_client_id => "app-12345", :brightbox_secret => "12345", :brightbox_username => "user@example.com", :brightbox_password => "abcde", :brightbox_account => "acc-abcde" } end before do stub_request(:get, "https://orbit.brightbox.com/v1"). to_return(authorized_response) end it "uses the configured account" do assert service.authenticate assert_equal "acc-abcde", service.account end end describe "when account is not configured" do let(:settings) do { :brightbox_client_id => "app-12345", :brightbox_secret => "12345", :brightbox_username => "user@example.com", :brightbox_password => "abcde" } end before do stub_request(:get, "https://orbit.brightbox.com/v1"). to_return(authorized_response) end it "extracts the account from the management URL" do assert service.authenticate assert_equal "acc-12345", service.account end end describe "when configured with existing token" do let(:settings) do { :brightbox_client_id => "app-12345", :brightbox_secret => "12345", :brightbox_access_token => "1234567890abcdefghijklmnopqrstuvwxyz", :brightbox_refresh_token => "1234567890abcdefghijklmnopqrstuvwxyz" } end it "does not need to authenticate" do refute service.needs_to_authenticate? end it "requires a call to discover management_url" do assert_nil service.management_url end end describe "when configured with tokens and management_url" do let(:settings) do { :brightbox_client_id => "app-12345", :brightbox_secret => "12345", :brightbox_access_token => "1234567890abcdefghijklmnopqrstuvwxyz", :brightbox_refresh_token => "1234567890abcdefghijklmnopqrstuvwxyz", :brightbox_storage_management_url => "https://files.gb2.brightbox.com/v1/acc-12345" } end it "does not need to authenticate" do refute service.needs_to_authenticate? end it "uses configured management_url" do assert_equal "https://files.gb2.brightbox.com/v1/acc-12345", service.management_url.to_s end it "keeps setting after authentication" do stub_request(:get, "https://orbit.brightbox.com/v1"). to_return(authorized_response) config.expire_tokens! service.authenticate assert_equal "https://files.gb2.brightbox.com/v1/acc-12345", service.management_url.to_s end end describe "when configured with expired tokens" do let(:settings) do { :brightbox_client_id => "app-12345", :brightbox_secret => "12345", :brightbox_access_token => "1234567890abcdefghijklmnopqrstuvwxyz", :brightbox_refresh_token => "1234567890abcdefghijklmnopqrstuvwxyz", :brightbox_storage_management_url => "https://files.gb2.brightbox.com/v1/acc-12345", :brightbox_token_management => false } end before do # Ongoing request but tokens are expired stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord"). to_return(unauthorized_response) end let(:params) { { :expects => [200], :path => "fnord" } } it "raises Fog::Brightbox::Storage::AuthenticationRequired" do assert_raises(Fog::Brightbox::Storage::AuthenticationRequired) { service.request(params) } end end describe "when configured with user details and expired tokens" do let(:settings) do { :brightbox_client_id => "app-12345", :brightbox_secret => "12345", :brightbox_username => "user@example.com", :brightbox_password => "12345", :brightbox_access_token => "1234567890abcdefghijklmnopqrstuvwxyz", :brightbox_refresh_token => "1234567890abcdefghijklmnopqrstuvwxyz", :brightbox_storage_url => "https://files.gb2.brightbox.com", :brightbox_storage_management_url => "https://files.gb2.brightbox.com/v1/acc-12345" } end before do # Ongoing request but tokens are expired stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord"). with(:headers => { "X-Auth-Token" => "1234567890abcdefghijklmnopqrstuvwxyz" }). to_return(unauthorized_response) # The reauthentication stub_request(:get, "https://files.gb2.brightbox.com/v1"). with(:headers => { "X-Auth-User" => "user@example.com", "X-Auth-Key" => "12345" }). to_return(authorized_response) # Repeated request stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord"). with(:headers => { "X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890" }). to_return(:status => 200) end let(:params) { { :expects => [200], :path => "fnord" } } it "authenticates again and retries" do service.request(params) pass end end describe "when configured with client credentials" do let(:settings) do { :brightbox_client_id => "cli-12345", :brightbox_secret => "12345" } end before do # Initial authentication stub_request(:get, "https://orbit.brightbox.com/v1"). with(:headers => { "X-Auth-Key" => "12345", "X-Auth-User" => "cli-12345" }). to_return(authorized_response) stub_request(:get, "https://orbit.brightbox.com/v1/acc-12345/fnord"). with(:headers => { "X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890" }). to_return(:status => 200) end let(:params) { { :expects => [200], :path => "fnord" } } it "authenticates again and retries" do service.request(params) pass end end describe "when not initialised with temporary URL key" do let(:settings) do { :brightbox_client_id => "cli-12345", :brightbox_secret => "12345" } end it "returns nil" do assert_nil config.storage_temp_key end it "fails to generate temporary URLs" do assert_raises(ArgumentError) { service.create_temp_url("container", "object", Time.now, "GET") } end end describe "when initialised with temporary URL key" do before { skip unless RUBY_VERSION > "1.9.3" } let(:temp_url_key) { "1234567890" } let(:settings) do { :brightbox_client_id => "cli-12345", :brightbox_secret => "12345", :brightbox_storage_management_url => "https://example.brightbox.com", :brightbox_temp_url_key => temp_url_key } end let(:container) { "container" } let(:object) { "file.ext" } let(:expiry_time) { Time.utc(2012) } let(:request_method) { "GET" } it "returns the key" do assert_equal temp_url_key, config.storage_temp_key end it "can generate temporary HTTPS URLs" do assert_equal "https://example.brightbox.com/container/file.ext?temp_url_sig=86dcfd2cf9d501936abab2badc152e90d6b3b133&temp_url_expires=1325376000", service.create_temp_url(container, object, expiry_time, request_method, :scheme => "https") end it "can generate temporary HTTP URLs" do assert_equal "http://example.brightbox.com/container/file.ext?temp_url_sig=86dcfd2cf9d501936abab2badc152e90d6b3b133&temp_url_expires=1325376000", service.create_temp_url(container, object, expiry_time, request_method, :scheme => "http") end it "can generate temporary HTTP URLs on non standard ports" do assert_equal "http://example.brightbox.com:401/container/file.ext?temp_url_sig=86dcfd2cf9d501936abab2badc152e90d6b3b133&temp_url_expires=1325376000", service.create_temp_url(container, object, expiry_time, request_method, :scheme => "http", :port => 401) end end end fog-brightbox-0.7.1/spec/fog/compute/0000755000004100000410000000000012464011624017471 5ustar www-datawww-datafog-brightbox-0.7.1/spec/fog/compute/brightbox_spec.rb0000644000004100000410000000337112464011624023024 0ustar www-datawww-datarequire "spec_helper" describe Fog::Compute::Brightbox do describe "when global config is available" do before do @arguments = { :brightbox_auth_url => "http://localhost", :brightbox_api_url => "http://localhost", :brightbox_client_id => "", :brightbox_secret => "", :brightbox_username => "", :brightbox_password => "", :brightbox_account => "" } @credential_guard = Minitest::Mock.new def @credential_guard.reject {} end Fog.stub :credentials, @credential_guard do @service = Fog::Compute::Brightbox.new(@arguments) end end it "responds to #request" do assert_respond_to @service, :request end it "responds to #request_access_token" do assert_respond_to @service, :request_access_token end it "responds to #wrapped_request" do assert_respond_to @service, :wrapped_request end end describe "when created without required arguments" do it "raises an error" do Fog.stub :credentials, {} do assert_raises ArgumentError do Fog::Compute::Brightbox.new({}) end end end end describe "when created with a Config object" do it "does not error" do @options = { :brightbox_client_id => "cli-12345", :brightbox_secret => "1234567890" } @config = Fog::Brightbox::Config.new(@options) @service = Fog::Compute::Brightbox.new(@config) pass end end describe "when created with Config missing required settings" do it "raises ArgumentError"do @config = Fog::Brightbox::Config.new({}) assert_raises ArgumentError do @service = Fog::Compute::Brightbox.new(@config) end end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/0000755000004100000410000000000012464011624021461 5ustar www-datawww-datafog-brightbox-0.7.1/spec/fog/compute/brightbox/server_spec.rb0000644000004100000410000000350112464011624024325 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/server" describe Fog::Compute::Brightbox::Server do include ModelSetup include SupportsResourceLocking subject { service.servers.new } describe "when asked for collection name" do it "responds 'servers'" do assert_equal "servers", subject.collection_name end end describe "when asked for resource name" do it "responds 'server'" do assert_equal "server", subject.resource_name end end describe "when snapshotting withi no options" do it "returns the server" do skip if RUBY_VERSION < "1.9" stub_request(:post, "http://localhost/1.0/servers/srv-12345/snapshot?account_id="). with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }). to_return(:status => 202, :body => %q({"id": "srv-12345"}), :headers => {}) @server = Fog::Compute::Brightbox::Server.new(:service => service, :id => "srv-12345") assert_kind_of Hash, @server.snapshot end end describe "when snapshotting with link option" do it "returns the new image" do skip if RUBY_VERSION < "1.9" link = "; rel=snapshot" stub_request(:post, "http://localhost/1.0/servers/srv-12345/snapshot"). with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }). to_return(:status => 202, :body => "{}", :headers => { "Link" => link }) stub_request(:get, "http://localhost/1.0/images/img-12345?account_id="). with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }). to_return(:status => 200, :body => %q({"id": "img-12345"})) @server = Fog::Compute::Brightbox::Server.new(:service => service, :id => "srv-12345") assert_kind_of Fog::Compute::Brightbox::Image, @server.snapshot(true) end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/server_group_spec.rb0000644000004100000410000000076612464011624025553 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/server_group" describe Fog::Compute::Brightbox::ServerGroup do include ModelSetup subject { service.server_groups.new } describe "when asked for collection name" do it "responds 'server_groups'" do assert_equal "server_groups", subject.collection_name end end describe "when asked for resource name" do it "responds 'server_group'" do assert_equal "server_group", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/flavor_spec.rb0000644000004100000410000000071512464011624024314 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/flavor" describe Fog::Compute::Brightbox::Flavor do include ModelSetup subject { service.flavors.new } describe "when asked for collection name" do it "responds 'flavors'" do assert_equal "flavors", subject.collection_name end end describe "when asked for resource name" do it "responds 'flavor'" do assert_equal "flavor", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/database_server_spec.rb0000644000004100000410000000374312464011624026161 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/database_server" describe Fog::Compute::Brightbox::DatabaseServer do include ModelSetup include SupportsResourceLocking subject { service.database_servers.new } describe "when asked for collection name" do it "responds 'database_servers'" do assert_equal "database_servers", subject.collection_name end end describe "when asked for resource name" do it "responds 'database_server'" do assert_equal "database_server", subject.resource_name end end describe "when snapshotting withi no options" do it "returns the database server" do skip if RUBY_VERSION < "1.9" stub_request(:post, "http://localhost/1.0/database_servers/dbs-12345/snapshot?account_id="). with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }). to_return(:status => 202, :body => %q({"id": "dbs-12345"}), :headers => {}) @database_server = Fog::Compute::Brightbox::DatabaseServer.new(:service => service, :id => "dbs-12345") assert @database_server.snapshot end end describe "when snapshotting with link option" do it "returns the new image" do skip if RUBY_VERSION < "1.9" link = "; rel=snapshot" stub_request(:post, "http://localhost/1.0/database_servers/dbs-12345/snapshot"). with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }). to_return(:status => 202, :body => "{}", :headers => { "Link" => link }) stub_request(:get, "http://localhost/1.0/database_snapshots/dbi-12345?account_id="). with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }). to_return(:status => 200, :body => %q({"id": "dbs-12345"})) @database_server = Fog::Compute::Brightbox::DatabaseServer.new(:service => service, :id => "dbs-12345") assert_kind_of Fog::Compute::Brightbox::DatabaseSnapshot, @database_server.snapshot(true) end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/user_collaboration_spec.rb0000644000004100000410000000104012464011624026701 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/user_collaboration" describe Fog::Compute::Brightbox::UserCollaboration do include ModelSetup subject { service.user_collaborations.new } describe "when asked for collection name" do it "responds 'user_collaborations'" do assert_equal "user_collaborations", subject.collection_name end end describe "when asked for resource name" do it "responds 'user_collaboration'" do assert_equal "user_collaboration", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/collaboration_spec.rb0000644000004100000410000000077612464011624025662 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/collaboration" describe Fog::Compute::Brightbox::Collaboration do include ModelSetup subject { service.collaborations.new } describe "when asked for collection name" do it "responds 'collaborations'" do assert_equal "collaborations", subject.collection_name end end describe "when asked for resource name" do it "responds 'collaboration'" do assert_equal "collaboration", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/cloud_ip_spec.rb0000644000004100000410000000073212464011624024620 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/cloud_ip" describe Fog::Compute::Brightbox::CloudIp do include ModelSetup subject { service.cloud_ips.new } describe "when asked for collection name" do it "responds 'cloud_ips'" do assert_equal "cloud_ips", subject.collection_name end end describe "when asked for resource name" do it "responds 'cloud_ip'" do assert_equal "cloud_ip", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/event_spec.rb0000644000004100000410000000070612464011624024144 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/event" describe Fog::Compute::Brightbox::Event do include ModelSetup subject { service.events.new } describe "when asked for collection name" do it "responds 'events'" do assert_equal "events", subject.collection_name end end describe "when asked for resource name" do it "responds 'event'" do assert_equal "event", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/account_spec.rb0000644000004100000410000000072412464011624024457 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/account" describe Fog::Compute::Brightbox::Account do include ModelSetup subject { service.accounts.new } describe "when asked for collection name" do it "responds 'accounts'" do assert_equal "accounts", subject.collection_name end end describe "when asked for resource name" do it "responds 'account'" do assert_equal "account", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/zone_spec.rb0000644000004100000410000000067712464011624024005 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/zone" describe Fog::Compute::Brightbox::Zone do include ModelSetup subject { service.zones.new } describe "when asked for collection name" do it "responds 'zones'" do assert_equal "zones", subject.collection_name end end describe "when asked for resource name" do it "responds 'zone'" do assert_equal "zone", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/user_spec.rb0000644000004100000410000000067712464011624024010 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/user" describe Fog::Compute::Brightbox::User do include ModelSetup subject { service.users.new } describe "when asked for collection name" do it "responds 'users'" do assert_equal "users", subject.collection_name end end describe "when asked for resource name" do it "responds 'user'" do assert_equal "user", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/image_spec.rb0000644000004100000410000000075012464011624024104 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/image" describe Fog::Compute::Brightbox::Image do include ModelSetup include SupportsResourceLocking subject { service.images.new } describe "when asked for collection name" do it "responds 'images'" do assert_equal "images", subject.collection_name end end describe "when asked for resource name" do it "responds 'image'" do assert_equal "image", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/api_client_spec.rb0000644000004100000410000000075012464011624025131 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/api_client" describe Fog::Compute::Brightbox::ApiClient do include ModelSetup subject { service.api_clients.new } describe "when asked for collection name" do it "responds 'api_clients'" do assert_equal "api_clients", subject.collection_name end end describe "when asked for resource name" do it "responds 'api_client'" do assert_equal "api_client", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/application_spec.rb0000644000004100000410000000076012464011624025326 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/application" describe Fog::Compute::Brightbox::Application do include ModelSetup subject { service.applications.new } describe "when asked for collection name" do it "responds 'applications'" do assert_equal "applications", subject.collection_name end end describe "when asked for resource name" do it "responds 'application'" do assert_equal "application", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/load_balancer_spec.rb0000644000004100000410000000103712464011624025567 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/load_balancer" describe Fog::Compute::Brightbox::LoadBalancer do include ModelSetup include SupportsResourceLocking subject { service.load_balancers.new } describe "when asked for collection name" do it "responds 'load_balancers'" do assert_equal "load_balancers", subject.collection_name end end describe "when asked for resource name" do it "responds 'load_balancer'" do assert_equal "load_balancer", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/database_type_spec.rb0000644000004100000410000000077512464011624025636 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/database_type" describe Fog::Compute::Brightbox::DatabaseType do include ModelSetup subject { service.database_types.new } describe "when asked for collection name" do it "responds 'database_types'" do assert_equal "database_types", subject.collection_name end end describe "when asked for resource name" do it "responds 'database_type'" do assert_equal "database_type", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/database_snapshot_spec.rb0000644000004100000410000000107312464011624026504 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/database_snapshot" describe Fog::Compute::Brightbox::DatabaseSnapshot do include ModelSetup include SupportsResourceLocking subject { service.database_snapshots.new } describe "when asked for collection name" do it "responds 'database_snapshots'" do assert_equal "database_snapshots", subject.collection_name end end describe "when asked for resource name" do it "responds 'database_snapshot'" do assert_equal "database_snapshot", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/compute/brightbox/firewall_policy_spec.rb0000644000004100000410000000101612464011624026202 0ustar www-datawww-datarequire "spec_helper" require "fog/brightbox/models/compute/firewall_policy" describe Fog::Compute::Brightbox::FirewallPolicy do include ModelSetup subject { service.firewall_policies.new } describe "when asked for collection name" do it "responds 'firewall_policies'" do assert_equal "firewall_policies", subject.collection_name end end describe "when asked for resource name" do it "responds 'firewall_policy'" do assert_equal "firewall_policy", subject.resource_name end end end fog-brightbox-0.7.1/spec/fog/brightbox/0000755000004100000410000000000012464011624020005 5ustar www-datawww-datafog-brightbox-0.7.1/spec/fog/brightbox/storage/0000755000004100000410000000000012464011624021451 5ustar www-datawww-datafog-brightbox-0.7.1/spec/fog/brightbox/storage/config_spec.rb0000644000004100000410000000206412464011624024257 0ustar www-datawww-datarequire "minitest/autorun" require "fog/brightbox" describe Fog::Brightbox::Storage::Config do describe "when required arguments are included" do it "nothing is raised" do settings = { :brightbox_client_id => "cli-12345", :brightbox_secret => "1234567890" } config = Fog::Brightbox::Config.new(settings) Fog::Brightbox::Storage::Config.new(config) pass end end describe "when client_id is not in configuration" do it "raises ArgumentError" do settings = { :brightbox_secret => "1234567890" } config = Fog::Brightbox::Config.new(settings) assert_raises ArgumentError do Fog::Brightbox::Storage::Config.new(config) end end end describe "when client_secret is not in configuration" do it "raises ArgumentError" do settings = { :brightbox_client_id => "cli-12345" } config = Fog::Brightbox::Config.new(settings) assert_raises ArgumentError do Fog::Brightbox::Storage::Config.new(config) end end end end fog-brightbox-0.7.1/spec/fog/brightbox/storage/connection_spec.rb0000644000004100000410000000746512464011624025163 0ustar www-datawww-datarequire "minitest/autorun" require "webmock/minitest" require "fog/brightbox" describe Fog::Brightbox::Storage::Connection do let(:config) { Fog::Brightbox::Config.new(settings) } let(:connection) { Fog::Brightbox::Storage::Connection.new(config) } let(:params) do { :path => "fnord", :expects => [200] } end let(:settings) do { :brightbox_client_id => "app-12345", :brightbox_secret => "1234567890", :brightbox_storage_management_url => "https://files.gb2.brightbox.com/v1/acc-12345" } end let(:valid_auth_token) { "01234567890abcdefghijklmnopqrstuvwxyz" } describe "when management URL is not available" do let(:settings) do { :brightbox_client_id => "app-12345", :brightbox_secret => "1234567890" } end it "raises Fog::Brightbox::Storage::ManagementUrlUnknown" do assert_raises(Fog::Brightbox::Storage::ManagementUrlUnknown) { connection.request(params) } end end describe "when parameters are nil" do let(:params) {} it "raises ArgumentError" do assert_raises(ArgumentError) { connection.request(params) } end end describe "when parameters are empty" do let(:params) { {} } before do stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345"). with(:headers => { "Accept" => "application/json", "Content-Type" => "application/json", "X-Auth-Token" => valid_auth_token }).to_return(:status => 200, :body => "{}", :headers => { "Content-Type" => "application/json" }) end it "completes successfully" do config.stub :latest_access_token, valid_auth_token do connection.request(params) pass end end end describe "when request should succeed" do before do stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord"). with(:headers => { "Accept" => "application/json", "Content-Type" => "application/json", "X-Auth-Token" => valid_auth_token }).to_return(:status => 200, :body => "{}", :headers => { "Content-Type" => "application/json" }) end it "completes successfully" do config.stub :latest_access_token, valid_auth_token do connection.request(params) pass end end end describe "when custom headers are passed" do let(:params) do { :headers => { "X-Test" => "present" }, :path => "fnord" } end it "completes successfully" do stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord"). with(:headers => { "X-Test" => "present" }).to_return(:status => 200) connection.request(params) pass end end describe "when container is not found" do it "raises Fog::Storage::Brightbox::NotFound" do stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord"). to_return(:status => 404, :body => "

Not Found

The resource could not be found.

", :headers => { "Content-Type" => "text/html" }) assert_raises(Fog::Storage::Brightbox::NotFound) { connection.request(params) } end end describe "when request is not authenticated" do it "raises Fog::Brightbox::Storage::AuthenticationRequired" do stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord"). to_return(:status => 401, :body => "Authentication required", :headers => { "Content-Type" => "text/plain" }) assert_raises(Fog::Brightbox::Storage::AuthenticationRequired) { connection.request(params) } end end end fog-brightbox-0.7.1/spec/fog/brightbox/storage/connection_errors_spec.rb0000644000004100000410000000371412464011624026550 0ustar www-datawww-datarequire "minitest/autorun" require "webmock/minitest" require "fog/brightbox" describe Fog::Brightbox::Storage::Connection do let(:config) { Fog::Brightbox::Config.new(settings) } let(:connection) { Fog::Brightbox::Storage::Connection.new(config) } let(:params) do { :path => "fnord", :expects => [200] } end let(:settings) do { :brightbox_client_id => "app-12345", :brightbox_secret => "1234567890", :brightbox_storage_management_url => "https://files.gb2.brightbox.com/v1/acc-12345" } end let(:valid_auth_token) { "01234567890abcdefghijklmnopqrstuvwxyz" } { 400 => Excon::Errors::BadRequest, 401 => Fog::Brightbox::Storage::AuthenticationRequired, 402 => Excon::Errors::PaymentRequired, 403 => Excon::Errors::Forbidden, 404 => Fog::Storage::Brightbox::NotFound, 405 => Excon::Errors::MethodNotAllowed, 406 => Excon::Errors::NotAcceptable, 407 => Excon::Errors::ProxyAuthenticationRequired, 408 => Excon::Errors::RequestTimeout, 409 => Excon::Errors::Conflict, 410 => Excon::Errors::Gone, 411 => Excon::Errors::LengthRequired, 412 => Excon::Errors::PreconditionFailed, 413 => Excon::Errors::RequestEntityTooLarge, 414 => Excon::Errors::RequestURITooLong, 415 => Excon::Errors::UnsupportedMediaType, 416 => Excon::Errors::RequestedRangeNotSatisfiable, 417 => Excon::Errors::ExpectationFailed, 422 => Excon::Errors::UnprocessableEntity, 500 => Excon::Errors::InternalServerError, 501 => Excon::Errors::NotImplemented, 502 => Excon::Errors::BadGateway, 503 => Excon::Errors::ServiceUnavailable, 504 => Excon::Errors::GatewayTimeout }.each do |status, error| describe "when request responds with #{status}" do it "raises #{error}" do stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord"). to_return(:status => status) assert_raises(error) { connection.request(params) } end end end end fog-brightbox-0.7.1/spec/fog/brightbox/storage/authentication_request_spec.rb0000644000004100000410000000573412464011624027610 0ustar www-datawww-datarequire "minitest/autorun" require "webmock/minitest" require "fog/brightbox" describe Fog::Brightbox::Storage::AuthenticationRequest do include StockStorageResponses describe "when initialised with blank config" do before do stub_request(:get, "https://orbit.brightbox.com/v1"). with(:headers => { "Host" => "orbit.brightbox.com:443", "X-Auth-User" => "", "X-Auth-Key" => "" }).to_return(bad_url_response) end it "raises error" do settings = {} @config = Fog::Brightbox::Config.new(settings) @request = Fog::Brightbox::Storage::AuthenticationRequest.new(@config) assert_raises(Excon::Errors::PreconditionFailed) { @request.authenticate } end end describe "when initialised with API client details" do before do stub_request(:get, "https://orbit.brightbox.com/v1"). with(:headers => { "Host" => "orbit.brightbox.com:443", "X-Auth-User" => "cli-12345", "X-Auth-Key" => "12345" }).to_return(authorized_response) end it "authenticates correctly" do settings = { :brightbox_client_id => "cli-12345", :brightbox_secret => "12345" } @config = Fog::Brightbox::Config.new(settings) @request = Fog::Brightbox::Storage::AuthenticationRequest.new(@config) assert @request.authenticate end end describe "when initialised with user details" do before do stub_request(:get, "https://orbit.brightbox.com/v1"). with(:headers => { "Host" => "orbit.brightbox.com:443", "X-Auth-User" => "user@example.com", "X-Auth-Key" => "abcde" }).to_return(authorized_response) end it "authenticates correctly" do settings = { :brightbox_client_id => "app-12345", :brightbox_secret => "12345", :brightbox_username => "user@example.com", :brightbox_password => "abcde" } @config = Fog::Brightbox::Config.new(settings) @request = Fog::Brightbox::Storage::AuthenticationRequest.new(@config) assert @request.authenticate end end describe "when initialised with bad user details" do before do stub_request(:get, "https://orbit.brightbox.com/v1"). with(:headers => { "Host" => "orbit.brightbox.com:443", "X-Auth-User" => "user@example.com", "X-Auth-Key" => "abcde" }).to_return(unauthorized_response) end it "raises error" do settings = { :brightbox_client_id => "app-12345", :brightbox_secret => "12345", :brightbox_username => "user@example.com", :brightbox_password => "abcde" } @config = Fog::Brightbox::Config.new(settings) @request = Fog::Brightbox::Storage::AuthenticationRequest.new(@config) assert_raises(Fog::Brightbox::Storage::AuthenticationRequired) { @request.authenticate } end end end fog-brightbox-0.7.1/spec/fog/brightbox/config_spec.rb0000644000004100000410000001634712464011624022624 0ustar www-datawww-datarequire "spec_helper" describe Fog::Brightbox::Config do it "can be used to config services" do @config = Fog::Brightbox::Config.new assert @config.config_service? end describe "when created with Fog.credentials" do it "does not error" do @config = Fog::Brightbox::Config.new(Fog.credentials) assert_instance_of Fog::Brightbox::Config, @config end end describe "when created with a Hash" do it "does not error" do @options = { :brightbox_client_id => "cli-12345" } @config = Fog::Brightbox::Config.new(@options) assert_instance_of Fog::Brightbox::Config, @config end end describe "when auth url options was passed" do it "returns the setting" do @options = { :brightbox_auth_url => "https://api.gb1.brightbox.com" } @config = Fog::Brightbox::Config.new(@options) assert_instance_of URI::HTTPS, @config.auth_url end end describe "when auth url is not specified" do it "returns the default" do @config = Fog::Brightbox::Config.new({}) assert_instance_of URI::HTTPS, @config.auth_url assert_equal "https://api.gb1.brightbox.com", @config.auth_url.to_s end end describe "when compute url options was passed" do it "returns the setting" do @options = { :brightbox_api_url => "https://api.gb1.brightbox.com" } @config = Fog::Brightbox::Config.new(@options) assert_instance_of URI::HTTPS, @config.compute_url assert_equal @config.compute_url, @config.api_url end end describe "when compute url is not specified" do it "returns the default" do @config = Fog::Brightbox::Config.new({}) assert_instance_of URI::HTTPS, @config.compute_url assert_equal "https://api.gb1.brightbox.com", @config.compute_url.to_s assert_equal @config.compute_url, @config.api_url end end describe "when client id is passed" do it "returns the settings" do @options = { :brightbox_client_id => "cli-12345" } @config = Fog::Brightbox::Config.new(@options) assert_equal "cli-12345", @config.client_id end end describe "when client secret is passed" do it "returns the settings" do @options = { :brightbox_secret => "secret" } @config = Fog::Brightbox::Config.new(@options) assert_equal "secret", @config.client_secret end end describe "when username is passed" do it "returns the settings" do @options = { :brightbox_username => "usr-12345" } @config = Fog::Brightbox::Config.new(@options) assert_equal "usr-12345", @config.username end end describe "when password is passed" do it "returns the settings" do @options = { :brightbox_password => "password" } @config = Fog::Brightbox::Config.new(@options) assert_equal "password", @config.password end end describe "when account is passed" do it "returns the settings" do @options = { :brightbox_account => "acc-12345" } @config = Fog::Brightbox::Config.new(@options) assert_equal "acc-12345", @config.account end end describe "when account was passed but changed" do it "returns the new account" do @options = { :brightbox_account => "acc-12345" } @config = Fog::Brightbox::Config.new(@options) @config.change_account("acc-abcde") assert_equal "acc-abcde", @config.account end end describe "when account was passed, changed and reset" do it "returns the original account" do @options = { :brightbox_account => "acc-12345" } @config = Fog::Brightbox::Config.new(@options) @config.change_account("acc-abcde") @config.reset_account assert_equal "acc-12345", @config.account end end describe "when connection options are passed" do it "returns the settings" do @connection_settings = { :headers => { "Content-Type" => "application/json" } } @options = { :connection_options => @connection_settings } @config = Fog::Brightbox::Config.new(@options) assert_equal @connection_settings, @config.connection_options end end describe "when no connection options were passed" do it "returns an empty hash" do @config = Fog::Brightbox::Config.new assert_equal({}, @config.connection_options) end end describe "when persistent connection is requested" do it "returns true for the setting" do @options = { :persistent => true } @config = Fog::Brightbox::Config.new(@options) assert @config.connection_persistent? end end describe "when persistent connection is not specified" do it "returns false by default" do @config = Fog::Brightbox::Config.new refute @config.connection_persistent? end end describe "when cached OAuth tokens were passed" do before do @access_token = "1234567890abcdefghijklmnopqrstuvwxyz" @refresh_token = "1234567890abcdefghijklmnopqrstuvwxyz" @options = { :brightbox_access_token => @access_token, :brightbox_refresh_token => @refresh_token } @config = Fog::Brightbox::Config.new(@options) end it "returns the access token" do assert_equal @access_token, @config.cached_access_token assert_equal @access_token, @config.latest_access_token end it "returns the refresh token" do assert_equal @refresh_token, @config.cached_refresh_token assert_equal @refresh_token, @config.latest_refresh_token end it "does not need to authenticate" do refute @config.must_authenticate? end it "can expire the tokens" do @config.expire_tokens! assert_nil @config.latest_access_token assert_nil @config.latest_refresh_token end end describe "when token management is not specified" do it "returns true by default" do @config = Fog::Brightbox::Config.new assert @config.managed_tokens? end end describe "when token management setting is disabled" do it "returns false" do @options = { :brightbox_token_management => false } @config = Fog::Brightbox::Config.new(@options) refute @config.managed_tokens? end end describe "when a default server image is configured" do it "returns the configured setting" do @options = { :brightbox_default_image => "img-12345" } @config = Fog::Brightbox::Config.new(@options) assert_equal "img-12345", @config.default_image_id end end describe "when a default server is not set" do it "returns nil" do @config = Fog::Brightbox::Config.new assert_nil @config.default_image_id end end describe "when username and password are given" do it "user_credentials? returns true" do @options = { :brightbox_client_id => "app-12345", :brightbox_secret => "12345", :brightbox_username => "user@example.com", :brightbox_password => "12345" } @config = Fog::Brightbox::Config.new(@options) assert @config.user_credentials? end end describe "when no username is given" do it "user_credentials? returns false" do @options = { :brightbox_client_id => "cli-12345", :brightbox_secret => "12345" } @config = Fog::Brightbox::Config.new(@options) refute @config.user_credentials? end end end fog-brightbox-0.7.1/spec/fog/brightbox/compute/0000755000004100000410000000000012464011624021461 5ustar www-datawww-datafog-brightbox-0.7.1/spec/fog/brightbox/compute/config_spec.rb0000644000004100000410000000202712464011624024266 0ustar www-datawww-datarequire "spec_helper" describe Fog::Brightbox::Compute::Config do describe "when required arguments are included" do it "nothing is raised" do settings = { :brightbox_client_id => "cli-12345", :brightbox_secret => "1234567890" } config = Fog::Brightbox::Config.new(settings) Fog::Brightbox::Compute::Config.new(config) pass end end describe "when client_id is not in configuration" do it "raises ArgumentError" do settings = { :brightbox_secret => "1234567890" } config = Fog::Brightbox::Config.new(settings) assert_raises ArgumentError do Fog::Brightbox::Compute::Config.new(config) end end end describe "when client_secret is not in configuration" do it "raises ArgumentError" do settings = { :brightbox_client_id => "cli-12345" } config = Fog::Brightbox::Config.new(settings) assert_raises ArgumentError do Fog::Brightbox::Compute::Config.new(config) end end end end fog-brightbox-0.7.1/spec/fog/brightbox/link_helper_spec.rb0000644000004100000410000000070412464011624023641 0ustar www-datawww-datarequire "spec_helper" describe Fog::Brightbox::LinkHelper do describe "when initialized with an RFC5988 value" do before do @header = "; rel=snapshot" @helper = Fog::Brightbox::LinkHelper.new(@header) end it "can return identifier" do assert_equal "img-12345", @helper.identifier end it "can return URI" do assert_kind_of URI, @helper.uri end end end fog-brightbox-0.7.1/spec/supports_resource_locking.rb0000644000004100000410000000204112464011624023100 0ustar www-datawww-datarequire "webmock/minitest" module SupportsResourceLocking def self.included(base) base.class_eval do let(:collection_name) { subject.collection_name } def test_responds_to_locked assert_respond_to subject, :locked? end def test_responds_to_lock assert_respond_to subject, :lock! end def test_lock_makes_request skip if RUBY_VERSION < "1.9" subject.id = "tst-12345" stub_request(:put, "http://localhost/1.0/#{collection_name}/tst-12345/lock_resource?account_id=").to_return(:status => 200, :body => "{}", :headers => {}) subject.lock! end def test_responds_to_unlock assert_respond_to subject, :unlock! end def test_unlock_makes_request skip if RUBY_VERSION < "1.9" subject.id = "tst-12345" stub_request(:put, "http://localhost/1.0/#{collection_name}/tst-12345/unlock_resource?account_id=").to_return(:status => 200, :body => "{}", :headers => {}) subject.unlock! end end end end fog-brightbox-0.7.1/.travis.yml0000644000004100000410000000017412464011624016423 0ustar www-datawww-datalanguage: ruby rvm: - 2.1.1 - 2.0.0 - 1.9.3 matrix: include: - rvm: 1.8.7 gemfile: gemfiles/Gemfile.1.8.7 fog-brightbox-0.7.1/lib/0000755000004100000410000000000012464011624015056 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/0000755000004100000410000000000012464011624015631 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/brightbox.rb0000644000004100000410000000010012464011624020135 0ustar www-datawww-datarequire "fog/brightbox/compute" require "fog/brightbox/storage" fog-brightbox-0.7.1/lib/fog/brightbox/0000755000004100000410000000000012464011624017621 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/brightbox/storage/0000755000004100000410000000000012464011624021265 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/brightbox/storage/authentication_request.rb0000644000004100000410000000266512464011624026412 0ustar www-datawww-datamodule Fog module Brightbox module Storage class AuthenticationRequest attr_accessor :access_token, :management_url attr_accessor :user, :tenant def initialize(config) @config = config end def authenticate response = authentication_request self.access_token = response.headers["X-Auth-Token"] self.management_url = response.headers["X-Server-Management-Url"] || response.headers["X-Storage-Url"] self rescue Excon::Errors::Unauthorized => error raise Fog::Brightbox::Storage::AuthenticationRequired.slurp(error) end private def authentication_request authentication_url = URI.parse(@config.storage_url.to_s) connection = Fog::Core::Connection.new(authentication_url.to_s) request_settings = { :expects => [200, 204], :headers => auth_headers, :method => "GET", :path => "v1" } connection.request(request_settings) end def auth_headers if @config.user_credentials? { "X-Auth-User" => @config.username, "X-Auth-Key" => @config.password } else { "X-Auth-User" => @config.client_id, "X-Auth-Key" => @config.client_secret } end end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/storage/connection.rb0000644000004100000410000000473512464011624023762 0ustar www-datawww-datarequire "fog/core/connection" require "fog/brightbox/storage/errors" module Fog module Brightbox module Storage class Connection < Fog::Core::Connection def initialize(config) @config = config if management_url @connection = super(management_url.to_s, persistent?, connection_options) else raise ManagementUrlUnknown end end def request(params, parse_json = true) begin raise ArgumentError if params.nil? request_params = params.merge( :headers => request_headers(params), :path => path_in_params(params) ) response = @connection.request(request_params) rescue Excon::Errors::Unauthorized => error raise AuthenticationRequired.slurp(error) rescue Excon::Errors::NotFound => error raise Fog::Storage::Brightbox::NotFound.slurp(error) rescue Excon::Errors::HTTPStatusError => error raise error end if !response.body.empty? && parse_json && response.get_header("Content-Type") =~ %r{application/json} response.body = Fog::JSON.decode(response.body) end response end def management_url @config.storage_management_url end def path_in_params(params) if params.respond_to?(:key?) && params.key?(:path) URI.join(@config.storage_management_url.to_s + "/", params[:path]).path else @config.storage_management_url.path end end def request_headers(excon_params) if excon_params.respond_to?(:key?) && excon_params.key?(:headers) authenticated_headers.merge(excon_params[:headers]) else authenticated_headers end end def authenticated_headers default_headers.merge( "X-Auth-Token" => @config.latest_access_token ) end def default_headers { "Content-Type" => "application/json", "Accept" => "application/json" } end def persistent? @config.connection_persistent? end def connection_options @config.storage_connection_options end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/storage/errors.rb0000644000004100000410000000030612464011624023125 0ustar www-datawww-datamodule Fog module Brightbox module Storage class ManagementUrlUnknown < Fog::Errors::Error end class AuthenticationRequired < Fog::Errors::Error end end end end fog-brightbox-0.7.1/lib/fog/brightbox/storage/config.rb0000644000004100000410000000072012464011624023056 0ustar www-datawww-datarequire "delegate" module Fog module Brightbox module Storage class Config < SimpleDelegator def initialize(config) super @config = config raise ArgumentError unless required_args_available? end private def required_args_available? return false unless @config.client_id return false unless @config.client_secret true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/model.rb0000644000004100000410000000024612464011624021250 0ustar www-datawww-datarequire "fog/core/model" require "fog/brightbox/model_helper" module Fog module Brightbox class Model < Fog::Model include ModelHelper end end end fog-brightbox-0.7.1/lib/fog/brightbox/link_helper.rb0000644000004100000410000000124512464011624022444 0ustar www-datawww-datamodule Fog module Brightbox # Rough implementation to extract Brightbox identifiers from RFC5988 Link headers # # @see https://tools.ietf.org/html/rfc5988 # class LinkHelper # @param [String] header The value assigned to the Link header def initialize(header) @header = header @parsed = false end def identifier parse unless @parsed uri.path.split("/")[3] end def uri parse unless @parsed URI.parse(@link) end private def parse match = @header.match(/\A<([^>]*)>/) @link = match[1] @parsed = true end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/0000755000004100000410000000000012464011624021474 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/0000755000004100000410000000000012464011624023140 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/get_container.rb0000644000004100000410000000330212464011624026304 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Get details for container and total bytes stored # # ==== Parameters # * container<~String> - Name of container to retrieve info for # * options<~String>: # * 'limit'<~String> - Maximum number of objects to return # * 'marker'<~String> - Only return objects whose name is greater than marker # * 'prefix'<~String> - Limits results to those starting with prefix # * 'path'<~String> - Return objects nested in the pseudo path # # ==== Returns # * response<~Excon::Response>: # * headers<~Hash>: # * 'X-Account-Container-Count'<~String> - Count of containers # * 'X-Account-Bytes-Used'<~String> - Bytes used # * body<~Array>: # * 'bytes'<~Integer> - Number of bytes used by container # * 'count'<~Integer> - Number of items in container # * 'name'<~String> - Name of container # * item<~Hash>: # * 'bytes'<~String> - Size of object # * 'content_type'<~String> Content-Type of object # * 'hash'<~String> - Hash of object (etag?) # * 'last_modified'<~String> - Last modified timestamp # * 'name'<~String> - Name of object def get_container(container, options = {}) options = options.reject { |_key, value| value.nil? } request( :expects => 200, :method => "GET", :path => Fog::Storage::Brightbox.escape(container), :query => { "format" => "json" }.merge!(options) ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/put_object.rb0000644000004100000410000000253112464011624025624 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Create a new object # # When passed a block, it will make a chunked request, calling # the block for chunks until it returns an empty string. # In this case the data parameter is ignored. # # ==== Parameters # * container<~String> - Name for container, should be < 256 bytes and must not contain '/' # * object<~String> - Name for object # * data<~String|File> - data to upload # * options<~Hash> - config headers for object. Defaults to {}. # * block<~Proc> - chunker # def put_object(container, object, data, options = {}, &block) if block_given? params = { :request_block => block } headers = options else data = Fog::Storage.parse_data(data) headers = data[:headers].merge!(options) params = { :body => data[:body] } end params.merge!( :expects => 201, :idempotent => !params[:request_block], :headers => headers, :method => "PUT", :path => "#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object)}" ) request(params) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/put_container.rb0000644000004100000410000000132012464011624026333 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Create a new container # # ==== Parameters # * name<~String> - Name for container, should be < 256 bytes and must not contain '/' # def put_container(name, options = {}) headers = options[:headers] || {} headers["X-Container-Read"] ||= options.delete(:read_permissions) headers["X-Container-Write"] ||= options.delete(:write_permissions) request( :expects => [201, 202], :method => "PUT", :path => Fog::Storage::Brightbox.escape(name), :headers => headers ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/head_object.rb0000644000004100000410000000112312464011624025711 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Get headers for object # # ==== Parameters # * container<~String> - Name of container to look in # * object<~String> - Name of object to look for # def head_object(container, object) request({ :expects => 200, :method => "HEAD", :path => "#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object)}" }, false) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/get_containers.rb0000644000004100000410000000175512464011624026501 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # List existing storage containers # # ==== Parameters # * options<~Hash>: # * 'limit'<~Integer> - Upper limit to number of results returned # * 'marker'<~String> - Only return objects with name greater than this value # # ==== Returns # * response<~Excon::Response>: # * body<~Array>: # * container<~Hash>: # * 'bytes'<~Integer>: - Number of bytes used by container # * 'count'<~Integer>: - Number of items in container # * 'name'<~String>: - Name of container def get_containers(options = {}) options = options.reject { |_key, value| value.nil? } request( :expects => [200, 204], :method => "GET", :path => "", :query => { "format" => "json" }.merge!(options) ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/put_object_manifest.rb0000644000004100000410000000057712464011624027522 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Create a new dynamic large object manifest # # This is an alias for {#put_dynamic_obj_manifest} for backward compatibility. def put_object_manifest(container, object, options = {}) put_dynamic_obj_manifest(container, object, options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/delete_container.rb0000644000004100000410000000066712464011624027002 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Delete an existing container # # ==== Parameters # * name<~String> - Name of container to delete # def delete_container(name) request( :expects => 204, :method => "DELETE", :path => Fog::Storage::Brightbox.escape(name) ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/post_set_meta_temp_url_key.rb0000644000004100000410000000211012464011624031104 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Set the account wide Temp URL Key. This is a secret key that's # used to generate signed expiring URLs. # # Once the key has been set with this request you should create new # Storage objects with the :brightbox_temp_url_key option then use # the get_object_https_url method to generate expiring URLs. # # *** CAUTION *** changing this secret key will invalidate any expiring # URLS generated with old keys. # # ==== Parameters # * key<~String> - The new Temp URL Key # # ==== Returns # * response<~Excon::Response> # # ==== See Also # http://docs.rackspace.com/files/api/v1/cf-devguide/content/Set_Account_Metadata-d1a4460.html def post_set_meta_temp_url_key(key) request( :expects => [201, 202, 204], :method => "POST", :headers => { "X-Account-Meta-Temp-Url-Key" => key } ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/put_dynamic_obj_manifest.rb0000644000004100000410000000426512464011624030530 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Create a new dynamic large object manifest # # Creates an object with a +X-Object-Manifest+ header that specifies the common prefix ("/") # for all uploaded segments. Retrieving the manifest object streams all segments matching this prefix. # Segments must sort in the order they should be concatenated. Note that any future objects stored in the container # along with the segments that match the prefix will be included when retrieving the manifest object. # # All segments must be stored in the same container, but may be in a different container than the manifest object. # The default +X-Object-Manifest+ header is set to "+container+/+object+", but may be overridden in +options+ # to specify the prefix and/or the container where segments were stored. # If overridden, names should be CGI escaped (excluding spaces) if needed (see {Fog::Storage::Brightbox.escape}). # # @param container [String] Name for container where +object+ will be stored. Should be < 256 bytes and must not contain '/' # @param object [String] Name for manifest object. # @param options [Hash] Config headers for +object+. # @option options [String] 'X-Object-Manifest' ("container/object") "/" for segment objects. # # @raise [Fog::Storage::Brightbox::NotFound] HTTP 404 # @raise [Excon::Errors::BadRequest] HTTP 400 # @raise [Excon::Errors::Unauthorized] HTTP 401 # @raise [Excon::Errors::HTTPStatusError] # # @see http://docs.brightbox.org/api/brightbox-object-storage/1.0/content/dynamic-large-object-creation.html def put_dynamic_obj_manifest(container, object, options = {}) path = "#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object)}" headers = { "X-Object-Manifest" => path }.merge(options) request( :expects => 201, :headers => headers, :method => "PUT", :path => path ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/delete_static_large_object.rb0000644000004100000410000000405312464011624031000 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Delete a static large object. # # Deletes the SLO manifest +object+ and all segments that it references. # The server will respond with +200 OK+ for all requests. # +response.body+ must be inspected for actual results. # # @param container [String] Name of container. # @param object [String] Name of the SLO manifest object. # @param options [Hash] Additional request headers. # # @return [Excon::Response] # * body [Hash] - Results of the operation. # * "Number Not Found" [Integer] - Number of missing segments. # * "Response Status" [String] - Response code for the subrequest of the last failed operation. # * "Errors" [Array] # * object_name [String] - Object that generated an error when the delete was attempted. # * response_status [String] - Response status from the subrequest for object_name. # * "Number Deleted" [Integer] - Number of segments deleted. # * "Response Body" [String] - Response body for Response Status. # # @see http://docs.brightbox.org/api/brightbox-object-storage/1.0/content/static-large-objects.html def delete_static_large_object(container, object, options = {}) response = request({ :expects => 200, :method => "DELETE", :headers => options.merge("Content-Type" => "text/plain", "Accept" => "application/json"), :path => "#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object)}", :query => { "multipart-manifest" => "delete" } }, false) response.body = Fog::JSON.decode(response.body) response end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/get_object_http_url.rb0000644000004100000410000000123112464011624027510 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Get an expiring object http url # # ==== Parameters # * container<~String> - Name of container containing object # * object<~String> - Name of object to get expiring url for # * expires<~Time> - An expiry time for this url # # ==== Returns # * response<~Excon::Response>: # * body<~String> - url for object def get_object_http_url(container, object, expires, options = {}) create_temp_url(container, object, expires, "GET", options.merge(:scheme => "http")) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/copy_object.rb0000644000004100000410000000200112464011624025756 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Copy object # # ==== Parameters # * source_container_name<~String> - Name of source bucket # * source_object_name<~String> - Name of source object # * target_container_name<~String> - Name of bucket to create copy in # * target_object_name<~String> - Name for new copy of object # * options<~Hash> - Additional headers def copy_object(source_container_name, source_object_name, target_container_name, target_object_name, options = {}) headers = { "X-Copy-From" => "/#{source_container_name}/#{source_object_name}" }.merge(options) request( :expects => 201, :headers => headers, :method => "PUT", :path => "#{Fog::Storage::Brightbox.escape(target_container_name)}/#{Fog::Storage::Brightbox.escape(target_object_name)}" ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/delete_object.rb0000644000004100000410000000105612464011624026257 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Delete an existing object # # ==== Parameters # * container<~String> - Name of container to delete # * object<~String> - Name of object to delete # def delete_object(container, object) request( :expects => 204, :method => "DELETE", :path => "#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object)}" ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/head_containers.rb0000644000004100000410000000113212464011624026610 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # List number of containers and total bytes stored # # ==== Returns # * response<~Excon::Response>: # * headers<~Hash>: # * 'X-Account-Container-Count'<~String> - Count of containers # * 'X-Account-Bytes-Used'<~String> - Bytes used def head_containers request( :expects => 204, :method => "HEAD", :path => "", :query => { "format" => "json" } ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/get_object_https_url.rb0000644000004100000410000000626412464011624027706 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Get an expiring object https url from Cloud Files # # ==== Parameters # * container<~String> - Name of container containing object # * object<~String> - Name of object to get expiring url for # * expires<~Time> - An expiry time for this url # # ==== Returns # * response<~Excon::Response>: # * body<~String> - url for object def get_object_https_url(container, object, expires, options = {}) create_temp_url(container, object, expires, "GET", options.merge(:scheme => "https")) end # creates a temporary url # # @param container [String] Name of container containing object # @param object [String] Name of object to get expiring url for # @param expires_at [Time] An expiry time for this url # @param method [String] The method to use for accessing the object (GET, PUT, HEAD) # @param options [Hash] An optional options hash # @option options [String] :scheme The scheme to use (http, https) # @option options [String] :port A non standard port to use # # @return [String] url for object # # @raise [ArgumentError] if +storage_temp_key+ is not set in configuration # @raise [ArgumentError] if +method+ is not valid # # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html # def create_temp_url(container, object, expires_at, method, options = {}) raise ArgumentError, "Storage must be instantiated with the :brightbox_temp_url_key option" if @config.storage_temp_key.nil? # POST not allowed allowed_methods = %w(GET PUT HEAD) unless allowed_methods.include?(method) raise ArgumentError.new("Invalid method '#{method}' specified. Valid methods are: #{allowed_methods.join(", ")}") end # This assumes we have access to the management URL at this point destination_url = management_url.dup object_path = destination_url.path destination_url.scheme = options[:scheme] if options[:scheme] destination_url.port = options[:port] if options[:port] object_path_escaped = "#{object_path}/#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object, "/")}" object_path_unescaped = "#{object_path}/#{Fog::Storage::Brightbox.escape(container)}/#{object}" expiry_timestamp = expires_at.to_i string_to_sign = [method, expiry_timestamp, object_path_unescaped].join("\n") hmac = Fog::HMAC.new("sha1", @config.storage_temp_key) sig = sig_to_hex(hmac.sign(string_to_sign)) destination_url.path = object_path_escaped destination_url.query = URI.encode_www_form(:temp_url_sig => sig, :temp_url_expires => expiry_timestamp) destination_url.to_s end private def sig_to_hex(str) str.unpack("C*").map { |c| c.to_s(16) }.map { |h| h.size == 1 ? "0#{h}" : h }.join end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/head_container.rb0000644000004100000410000000136712464011624026437 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # List number of objects and total bytes stored # # ==== Parameters # * container<~String> - Name of container to retrieve info for # # ==== Returns # * response<~Excon::Response>: # * headers<~Hash>: # * 'X-Container-Object-Count'<~String> - Count of containers # * 'X-Container-Bytes-Used'<~String> - Bytes used def head_container(container) request( :expects => 204, :method => "HEAD", :path => Fog::Storage::Brightbox.escape(container), :query => { "format" => "json" } ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/put_static_obj_manifest.rb0000644000004100000410000000536512464011624030375 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Create a new static large object manifest. # # A static large object is similar to a dynamic large object. Whereas a GET for a dynamic large object manifest # will stream segments based on the manifest's +X-Object-Manifest+ object name prefix, a static large object # manifest streams segments which are defined by the user within the manifest. Information about each segment is # provided in +segments+ as an Array of Hash objects, ordered in the sequence which the segments should be streamed. # # When the SLO manifest is received, each segment's +etag+ and +size_bytes+ will be verified. # The +etag+ for each segment is returned in the response to {#put_object}, but may also be calculated. # e.g. +Digest::MD5.hexdigest(segment_data)+ # # The maximum number of segments for a static large object is 1000, and all segments (except the last) must be # at least 1 MiB in size. Unlike a dynamic large object, segments are not required to be in the same container. # # @example # segments = [ # { :path => 'segments_container/first_segment', # :etag => 'md5 for first_segment', # :size_bytes => 'byte size of first_segment' }, # { :path => 'segments_container/second_segment', # :etag => 'md5 for second_segment', # :size_bytes => 'byte size of second_segment' } # ] # put_static_obj_manifest('my_container', 'my_large_object', segments) # # @param container [String] Name for container where +object+ will be stored. # Should be < 256 bytes and must not contain '/' # @param object [String] Name for manifest object. # @param segments [Array] Segment data for the object. # @param options [Hash] Config headers for +object+. # # @raise [Fog::Storage::Brightbox::NotFound] HTTP 404 # @raise [Excon::Errors::BadRequest] HTTP 400 # @raise [Excon::Errors::Unauthorized] HTTP 401 # @raise [Excon::Errors::HTTPStatusError] # # @see http://docs.brightbox.org/api/brightbox-object-storage/1.0/content/static-large-objects.html def put_static_obj_manifest(container, object, segments, options = {}) request( :expects => 201, :method => "PUT", :headers => options, :body => Fog::JSON.encode(segments), :path => "#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object)}", :query => { "multipart-manifest" => "put" } ) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/get_object.rb0000644000004100000410000000125112464011624025571 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Get details for object # # ==== Parameters # * container<~String> - Name of container to look in # * object<~String> - Name of object to look for # def get_object(container, object, &block) params = { :expects => 200, :method => "GET", :path => "#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object)}" } if block_given? params[:response_block] = block end request(params, false) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/storage/delete_multiple_objects.rb0000644000004100000410000000633112464011624030356 0ustar www-datawww-datamodule Fog module Storage class Brightbox class Real # Deletes multiple objects or containers with a single request. # # To delete objects from a single container, +container+ may be provided # and +object_names+ should be an Array of object names within the container. # # To delete objects from multiple containers or delete containers, # +container+ should be +nil+ and all +object_names+ should be prefixed with a container name. # # Containers must be empty when deleted. +object_names+ are processed in the order given, # so objects within a container should be listed first to empty the container. # # Up to 10,000 objects may be deleted in a single request. # The server will respond with +200 OK+ for all requests. # +response.body+ must be inspected for actual results. # # @example Delete objects from a container # object_names = ['object', 'another/object'] # conn.delete_multiple_objects('my_container', object_names) # # @example Delete objects from multiple containers # object_names = ['container_a/object', 'container_b/object'] # conn.delete_multiple_objects(nil, object_names) # # @example Delete a container and all it's objects # object_names = ['my_container/object_a', 'my_container/object_b', 'my_container'] # conn.delete_multiple_objects(nil, object_names) # # @param container [String,nil] Name of container. # @param object_names [Array] Object names to be deleted. # @param options [Hash] Additional request headers. # # @return [Excon::Response] # * body [Hash] - Results of the operation. # * "Number Not Found" [Integer] - Number of missing objects or containers. # * "Response Status" [String] - Response code for the subrequest of the last failed operation. # * "Errors" [Array] # * object_name [String] - Object that generated an error when the delete was attempted. # * response_status [String] - Response status from the subrequest for object_name. # * "Number Deleted" [Integer] - Number of objects or containers deleted. # * "Response Body" [String] - Response body for "Response Status". def delete_multiple_objects(container, object_names, options = {}) body = object_names.map do |name| object_name = container ? "#{ container }/#{ name }" : name URI.encode(object_name) end.join("\n") response = request({ :expects => 200, :method => "DELETE", :headers => options.merge("Content-Type" => "text/plain", "Accept" => "application/json"), :body => body, :query => { "bulk-delete" => true } }, false) response.body = Fog::JSON.decode(response.body) response end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/0000755000004100000410000000000012464011624023150 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_database_type.rb0000644000004100000410000000113312464011624027137 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get details of the database server type. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_type_get_database_type # def get_database_type(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/database_types/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/add_listeners_load_balancer.rb0000644000004100000410000000164112464011624031145 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Adds a number of listeners to the load balancer to enable balancing across nodes for those settings. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [Array] :listeners Array of Listener parameters. Timeout is optional and specified in milliseconds. # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_add_listeners_load_balancer # def add_listeners_load_balancer(identifier, options) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/load_balancers/#{identifier}/add_listeners", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_cloud_ip.rb0000644000004100000410000000177112464011624026643 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some details of the cloud IP address. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :reverse_dns Reverse DNS hostname # @option options [String] :name Name for Cloud IP # @option options [Array] :port_translators Port on which external clients connect and port on which your service is listening. # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#cloud_ip_update_cloud_ip # def update_cloud_ip(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/cloud_ips/#{identifier}", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/add_servers_server_group.rb0000644000004100000410000000217412464011624030604 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Add a number of servers to the server group. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [Array] :servers Array of Hashes containing # +{"server" => server_id}+ for each server to add # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#server_group_add_servers_server_group # # @example # options = { # :servers => [ # {"server" => "srv-abcde"}, # {"server" => "srv-fghij"} # ] # } # Compute[:brightbox].add_servers_server_group "grp-12345", options # def add_servers_server_group(identifier, options) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/server_groups/#{identifier}/add_servers", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_firewall_policy.rb0000644000004100000410000000152512464011624030206 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Destroy the firewall policy if not in use. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#firewall_policy_delete_firewall_policy # def delete_firewall_policy(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/firewall_policies/#{identifier}", [202]) end # Old format of the delete request. # # @deprecated Use +#delete_firewall_policy+ instead # def destroy_firewall_policy(identifier) delete_firewall_policy(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_scoped_account.rb0000644000004100000410000000050012464011624027320 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Requests details about currently scoped account # # @return [Hash] The JSON response parsed to a Hash def get_scoped_account wrapped_request("get", "/1.0/account", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_collaboration.rb0000644000004100000410000000112512464011624027163 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Shows details of the collaboration # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#collaboration_get_collaboration # def get_collaboration(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/collaborations/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_api_clients.rb0000644000004100000410000000070012464011624027017 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of API clients owned by the account. # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#api_client_list_api_clients # def list_api_clients wrapped_request("get", "/1.0/api_clients", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/reset_secret_api_client.rb0000644000004100000410000000150412464011624030353 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Resets the secret used by the API client to a new generated value. # # The response is the only time the new secret is available in plaintext. # # Already authenticated tokens will still continue to be valid until expiry. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#api_client_reset_secret_api_client # def reset_secret_api_client(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/api_clients/#{identifier}/reset_secret", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_database_server.rb0000644000004100000410000000104612464011624027467 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_server_get_database_server # def get_database_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/database_servers/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_load_balancer.rb0000644000004100000410000000113112464011624027076 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the load balancer. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_get_load_balancer # def get_load_balancer(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/load_balancers/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/remove_firewall_policy.rb0000644000004100000410000000145212464011624030240 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Removes firewall policy from given server group # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :server_group Server Group to remove # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#firewall_policy_remove_firewall_policy # def remove_firewall_policy(identifier, options) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/firewall_policies/#{identifier}/remove", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/unlock_resource_server.rb0000644000004100000410000000105212464011624030263 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_unlock_resource_server # def unlock_resource_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("put", "/1.0/servers/#{identifier}/unlock_resource", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_user.rb0000644000004100000410000000166212464011624025317 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the user. # # @overload get_user(identifier) # @param [String] identifier Unique reference to identify the resource # # @overload get_user() # @deprecated Use {Fog::Compute::Brightbox::Real#get_authenticated_user} instead # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#user_get_user # def get_user(identifier = nil) if identifier.nil? || identifier == "" Fog::Logger.deprecation("get_user() without a parameter is deprecated, use get_authenticated_user instead [light_black](#{caller.first})[/]") get_authenticated_user else wrapped_request("get", "/1.0/users/#{identifier}", [200]) end end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/remove_servers_server_group.rb0000644000004100000410000000220612464011624031345 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Remove a number of servers from the server group. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [Array] :servers Array of Hashes containing # +{"server" => server_id}+ for each server # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#server_group_remove_servers_server_group # # @example # options = { # :servers => [ # {"server" => "srv-abcde"}, # {"server" => "srv-fghij"} # ] # } # Compute[:brightbox].remove_servers_server_group "grp-12345", options # def remove_servers_server_group(identifier, options) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/server_groups/#{identifier}/remove_servers", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/lock_resource_image.rb0000644000004100000410000000104012464011624027471 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#image_lock_resource_image # def lock_resource_image(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("put", "/1.0/images/#{identifier}/lock_resource", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/lock_resource_load_balancer.rb0000644000004100000410000000110012464011624031152 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_lock_resource_load_balancer # def lock_resource_load_balancer(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("put", "/1.0/load_balancers/#{identifier}/lock_resource", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/lock_resource_server.rb0000644000004100000410000000104412464011624027721 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_lock_resource_server # def lock_resource_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("put", "/1.0/servers/#{identifier}/lock_resource", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_cloud_ip.rb0000644000004100000410000000111012464011624026123 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the cloud IP address. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#cloud_ip_get_cloud_ip # def get_cloud_ip(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/cloud_ips/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb0000644000004100000410000000121312464011624030677 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Accepts the collaboration giving access to the account # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#user_collaboration_accept_user_collaboration # def accept_user_collaboration(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/user/collaborations/#{identifier}/accept", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_image.rb0000644000004100000410000000241212464011624026101 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Create a new image for the account by registering it against an image stored within the Brightbox cloud image library. # # The disk image must be in place before you can attempt to create a reference in the API. # # @param [Hash] options # @option options [String] :source Filename of the image file uploaded to /incoming via FTP # @option options [String] :arch OS architecture this image is built for # @option options [String] :name Name for this image. If no name is specified, a name will be autogenerated based on the source filename & current time. Can be modified later. # @option options [String] :username Username for the image # @option options [Boolean] :public # @option options [Boolean] :compatibility_mode # @option options [String] :description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#image_create_image # def create_image(options) wrapped_request("post", "/1.0/images", [201], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_zone.rb0000644000004100000410000000105412464011624025307 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the zone. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#zone_get_zone # def get_zone(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/zones/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_server.rb0000644000004100000410000000106612464011624025645 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the server. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_get_server # def get_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/servers/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_firewall_policy.rb0000644000004100000410000000161412464011624030225 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Updates details of the firewall policy # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name Editable label # @option options [String] :description Longer editable description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#firewall_policy_update_firewall_policy # def update_firewall_policy(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/firewall_policies/#{identifier}", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_application.rb0000644000004100000410000000116512464011624027326 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Create a new application for the user. # # @param [Hash] options # @option options [String] :name # @option options [String] :description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#application_create_application # def create_application(options) wrapped_request("post", "/1.0/applications", [201], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_collaborations.rb0000644000004100000410000000070412464011624027544 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists all the collaborations for the given account # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#collaboration_list_collaborations # def list_collaborations wrapped_request("get", "/1.0/collaborations", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/snapshot_database_server.rb0000644000004100000410000000226412464011624030552 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [Boolean] :return_link Return the Link header as a second return value # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_server_snapshot_database_server # def snapshot_database_server(identifier, options = {}) return nil if identifier.nil? || identifier == "" method = "POST" path = "/1.0/database_servers/#{identifier}/snapshot" expected = [202] if options[:return_link] request_parameters = { :method => method, :path => path, :expects => expected } response = request(request_parameters) data = Fog::JSON.decode(response.body) image_id = Fog::Brightbox::LinkHelper.new(response.headers["Link"]).identifier return data, image_id else wrapped_request(method, path, expected) end end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/reset_password_database_server.rb0000644000004100000410000000111412464011624031750 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_server_reset_password_database_server # def reset_password_database_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/database_servers/#{identifier}/reset_password", [202]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_server.rb0000644000004100000410000000143012464011624026323 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Destroy the server and free up the resources. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_delete_server # def delete_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/servers/#{identifier}", [202]) end # Old format of the delete request. # # @deprecated Use +#delete_server+ instead # def destroy_server(identifier) delete_server(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_cloud_ip.rb0000644000004100000410000000144712464011624026624 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Requests a new cloud IP address for the account. # # @param [Hash] options # @option options [String] :reverse_dns Reverse DNS hostname # @option options [String] :name Name for Cloud IP # @option options [Array] :port_translators Port on which external clients connect and port on which your service is listening. # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#cloud_ip_create_cloud_ip # def create_cloud_ip(options = {}) wrapped_request("post", "/1.0/cloud_ips", [201], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb0000644000004100000410000000115612464011624030722 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Rejects the collaboration # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#user_collaboration_reject_user_collaboration # def reject_user_collaboration(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/user/collaborations/#{identifier}/reject", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/remove_nodes_load_balancer.rb0000644000004100000410000000145512464011624031015 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Remove a number of nodes from the load balancer # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [Array] :nodes Array of Node parameters # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_remove_nodes_load_balancer # def remove_nodes_load_balancer(identifier, options) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/load_balancers/#{identifier}/remove_nodes", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_application.rb0000644000004100000410000000152112464011624027341 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some details of the application. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name # @option options [String] :description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#application_update_application # def update_application(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/applications/#{identifier}", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_api_client.rb0000644000004100000410000000116312464011624027130 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Create a new API client for the account. # # @param [Hash] options # @option options [String] :name # @option options [String] :description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#api_client_create_api_client # def create_api_client(options) wrapped_request("post", "/1.0/api_clients", [201], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_images.rb0000644000004100000410000000074012464011624025776 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of images available for use by the Account. It includes those available to all customers # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#image_list_images # def list_images wrapped_request("get", "/1.0/images", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/unlock_resource_image.rb0000644000004100000410000000104612464011624030042 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#image_unlock_resource_image # def unlock_resource_image(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("put", "/1.0/images/#{identifier}/unlock_resource", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_load_balancer.rb0000644000004100000410000000146412464011624027572 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Destroy the LoadBalancer # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_delete_load_balancer # def delete_load_balancer(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/load_balancers/#{identifier}", [202]) end # Old format of the delete request. # # @deprecated Use +#delete_load_balancer+ instead # def destroy_load_balancer(identifier) delete_load_balancer(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_firewall_rule.rb0000644000004100000410000000222512464011624027674 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some settings of the firewall rule. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :protocol # @option options [String] :source Required unless destination is set. # @option options [String] :source_port # @option options [String] :destination Required unless source is set # @option options [String] :destination_port # @option options [String] :icmp_type_name # @option options [String] :description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#firewall_rule_update_firewall_rule # def update_firewall_rule(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/firewall_rules/#{identifier}", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/shutdown_server.rb0000644000004100000410000000113512464011624026736 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Will issue a safe shutdown request for the server. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_shutdown_server # def shutdown_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/servers/#{identifier}/shutdown", [202]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/stop_server.rb0000644000004100000410000000113312464011624026046 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Will issue a stop request for the server to become inactive. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_stop_server # def stop_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/servers/#{identifier}/stop", [202]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_database_server.rb0000644000004100000410000000154212464011624030154 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [Hash] options # @option options [String] :name # @option options [String] :description # @option options [String] :engine Database engine to request # @option options [String] :version Database version to request # @option options [Array] :allow_access ... # @option options [String] :snapshot # @option options [String] :zone # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#database_server_create_database_server # def create_database_server(options) wrapped_request("post", "/1.0/database_servers", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_database_server.rb0000644000004100000410000000142512464011624030153 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_server_delete_database_server # def delete_database_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/database_servers/#{identifier}", [202]) end # Old format of the delete request. # # @deprecated Use +#delete_database_server+ instead # def destroy_database_server(identifier) delete_database_server(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_database_servers.rb0000644000004100000410000000060512464011624030046 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_server_list_database_servers # def list_database_servers wrapped_request("get", "/1.0/database_servers", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_cloud_ips.rb0000644000004100000410000000067712464011624026523 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of cloud IP addresses owned by the account. # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#cloud_ip_list_cloud_ips # def list_cloud_ips wrapped_request("get", "/1.0/cloud_ips", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_user_collaboration.rb0000644000004100000410000000116312464011624030223 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Shows details of the specified collaboration # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#user_collaboration_get_user_collaboration # def get_user_collaboration(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/user/collaborations/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb0000644000004100000410000000230412464011624031125 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Reset the image library ftp password for the account. # # @note The response is the only time the new password is available in plaintext. # # @overload reset_ftp_password_account(identifier) # @param [String] identifier Unique reference to identify the resource # # @overload reset_ftp_password_account() # @deprecated Use {Fog::Compute::Brightbox::Real#reset_ftp_password_scoped_account} instead # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#account_reset_ftp_password_account # def reset_ftp_password_account(identifier = nil) if identifier.nil? || identifier.empty? Fog::Logger.deprecation("reset_ftp_password_account() without a parameter is deprecated, use reset_ftp_password_scoped_account instead [light_black](#{caller.first})[/]") reset_ftp_password_scoped_account else wrapped_request("post", "/1.0/accounts/#{identifier}/reset_ftp_password", [200]) end end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_server_types.rb0000644000004100000410000000071112464011624027261 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of server types available to the account. # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_type_list_server_types # def list_server_types wrapped_request("get", "/1.0/server_types", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_firewall_policy.rb0000644000004100000410000000146512464011624030212 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Create a new firewall policy for the account. # # Optionally applying to a server group at creation time. # # @param [Hash] options # @option options [String] :server_group # @option options [String] :name Editable label # @option options [String] :description Longer editable description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#firewall_policy_create_firewall_policy # def create_firewall_policy(options) wrapped_request("post", "/1.0/firewall_policies", [201], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_application.rb0000644000004100000410000000144612464011624027327 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Destroy the application. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#application_delete_application # def delete_application(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/applications/#{identifier}", [200]) end # Old format of the delete request. # # @deprecated Use +#delete_application+ instead # def destroy_application(identifier) delete_application(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/reset_server.rb0000644000004100000410000000112612464011624026205 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Resets the server without disconnecting the console. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_reset_server # def reset_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/servers/#{identifier}/reset", [202]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_firewall_rule.rb0000644000004100000410000000176512464011624027665 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Create a new firewall rule for a firewall policy. # # @param [Hash] options # @option options [String] :firewall_policy # @option options [String] :protocol # @option options [String] :source Required unless destination is set. # @option options [String] :source_port # @option options [String] :destination Required unless source is set # @option options [String] :destination_port # @option options [String] :icmp_type_name # @option options [String] :description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#firewall_rule_create_firewall_rule # def create_firewall_rule(options) wrapped_request("post", "/1.0/firewall_rules", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_server_group.rb0000644000004100000410000000125312464011624027543 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Create a new server group for the account. # # @param [Hash] options # @option options [String] :name Editable user label # @option options [String] :description Editable user description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#server_group_create_server_group # def create_server_group(options) wrapped_request("post", "/1.0/server_groups", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_account.rb0000644000004100000410000000550412464011624026477 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some details of the account. # # @overload update_account(identifier, options) # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name Account name # @option options [String] :address_1 First line of address # @option options [String] :address_2 Second line of address # @option options [String] :city City part of address # @option options [String] :county County part of address # @option options [String] :postcode Postcode or Zipcode # @option options [String] :country_code ISO 3166-1 two letter code (example: `GB`) # @option options [String] :vat_registration_number Must be a valid EU VAT number or `nil` # @option options [String] :telephone_number Valid International telephone number in E.164 format prefixed with `+` # # @overload update_account(options) # @deprecated Use {Fog::Compute::Brightbox::Real#update_scoped_account} instead # # @param [Hash] options # @option options [String] :name Account name # @option options [String] :address_1 First line of address # @option options [String] :address_2 Second line of address # @option options [String] :city City part of address # @option options [String] :county County part of address # @option options [String] :postcode Postcode or Zipcode # @option options [String] :country_code ISO 3166-1 two letter code (example: `GB`) # @option options [String] :vat_registration_number Must be a valid EU VAT number or `nil` # @option options [String] :telephone_number Valid International telephone number in E.164 format prefixed with `+` # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#account_update_account # def update_account(*args) if args.size == 2 identifier = args[0] options = args[1] elsif args.size == 1 options = args[0] else raise ArgumentError, "wrong number of arguments (0 for 2)" end return nil if options.empty? || options.nil? if identifier.nil? || identifier.empty? Fog::Logger.deprecation("update_account() without a parameter is deprecated, use update_scoped_account instead [light_black](#{caller.first})[/]") update_scoped_account(options) else wrapped_request("put", "/1.0/accounts/#{identifier}", [200], options) end end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_server_group.rb0000644000004100000410000000111712464011624027056 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get details of the server group. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_group_get_server_group # def get_server_group(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/server_groups/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/reset_ftp_password_scoped_account.rb0000644000004100000410000000073612464011624032471 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Resets the image library ftp password for the scoped account # # @note The response is the only time the new password is available in plaintext. # # @return [Hash] The JSON response parsed to a Hash # def reset_ftp_password_scoped_account wrapped_request("post", "/1.0/account/reset_ftp_password", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_firewall_policies.rb0000644000004100000410000000070712464011624030230 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of firewall policies # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#firewall_policy_list_firewall_policies # def list_firewall_policies wrapped_request("get", "/1.0/firewall_policies", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_load_balancers.rb0000644000004100000410000000071712464011624027466 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of load balancers owned by the account. # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_list_load_balancers # def list_load_balancers wrapped_request("get", "/1.0/load_balancers", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_database_types.rb0000644000004100000410000000065512464011624027526 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # List database server types. # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_type_list_database_types # def list_database_types wrapped_request("get", "/1.0/database_types", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_api_client.rb0000644000004100000410000000151412464011624027147 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some details of the API client. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name # @option options [String] :description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#api_client_update_api_client # def update_api_client(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/api_clients/#{identifier}", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_server.rb0000644000004100000410000000174012464011624026347 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some details of the server. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name Editable label # @option options [String] :user_data User defined metadata # @option options [Boolean] :compatibility_mode Server needs to be shutdown and restarted for changes to this to take effect # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#server_update_server # def update_server(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/servers/#{identifier}", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/remove_listeners_load_balancer.rb0000644000004100000410000000157012464011624031713 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Removes a number of listeners from a load balancer to cease balancing across nodes for those settings. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [Array] :listeners Array of Listener parameters # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_remove_listeners_load_balancer # def remove_listeners_load_balancer(identifier, options) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/load_balancers/#{identifier}/remove_listeners", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_zones.rb0000644000004100000410000000064612464011624025674 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of zones available to the account. # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#zone_list_zones # def list_zones wrapped_request("get", "/1.0/zones", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_database_snapshots.rb0000644000004100000410000000061512464011624030400 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_snapshot_list_database_snapshots # def list_database_snapshots wrapped_request("get", "/1.0/database_snapshots", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_cloud_ip.rb0000644000004100000410000000146312464011624026621 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Release the cloud IP address from the account's ownership. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#cloud_ip_delete_cloud_ip # def delete_cloud_ip(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/cloud_ips/#{identifier}", [200]) end # Old format of the delete request. # # @deprecated Use +#delete_cloud_ip+ instead # def destroy_cloud_ip(identifier) delete_cloud_ip(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_database_server.rb0000644000004100000410000000153112464011624030171 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name # @option options [String] :description # @option options [Array] :allow_access ... # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#database_server_update_database_server # def update_database_server(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/database_servers/#{identifier}", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_database_snapshot.rb0000644000004100000410000000144312464011624030504 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_snapshot_delete_database_snapshot # def delete_database_snapshot(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/database_snapshots/#{identifier}", [202]) end # Old format of the delete request. # # @deprecated Use +#delete_database_snapshot+ instead # def destroy_database_snapshot(identifier) delete_database_snapshot(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/start_server.rb0000644000004100000410000000113512464011624026220 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Will issue a start request for the server to become active. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_start_server # def start_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/servers/#{identifier}/start", [202]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_events.rb0000644000004100000410000000136712464011624026043 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists events related to the account. # # @api private # # @param [Hash] options # @option options [String] :limit Limit of pagination # @option options [String] :offset Offset of pagination # @option options [String] :resource_id Filter events for given resource_id # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#event_list_events # def list_events(options = {}) wrapped_request("get", "/1.0/events", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_database_snapshot.rb0000644000004100000410000000160212464011624030521 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some details of the server. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name Editable label # @option options [String] :description Editable label # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#database_snapshot_update_database_snapshot # def update_database_snapshot(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/database_snapshots/#{identifier}", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_scoped_account.rb0000644000004100000410000000241712464011624030034 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Requests an update to the currently scoped account # # @param [Hash] options # @option options [String] :name Account name # @option options [String] :address_1 First line of address # @option options [String] :address_2 Second line of address # @option options [String] :city City part of address # @option options [String] :county County part of address # @option options [String] :postcode Postcode or Zipcode # @option options [String] :country_code ISO 3166-1 two letter code (example: `GB`) # @option options [String] :vat_registration_number Must be a valid EU VAT number or `nil` # @option options [String] :telephone_number Valid International telephone number in E.164 format prefixed with `+` # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#account_update_account # def update_scoped_account(options) return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/account", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_server_groups.rb0000644000004100000410000000071212464011624027435 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of server groups owned by the account. # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_group_list_server_groups # def list_server_groups wrapped_request("get", "/1.0/server_groups", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/add_nodes_load_balancer.rb0000644000004100000410000000143712464011624030250 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Add a number of nodes to the load balancer # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [Array] :nodes Array of Node parameters # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_add_nodes_load_balancer # def add_nodes_load_balancer(identifier, options) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/load_balancers/#{identifier}/add_nodes", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_servers.rb0000644000004100000410000000065412464011624026226 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of servers owned by the account. # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_list_servers # def list_servers wrapped_request("get", "/1.0/servers", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/activate_console_server.rb0000644000004100000410000000117612464011624030412 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Enable console access via VNC to the server for 15 minutes. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_activate_console_server # def activate_console_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/servers/#{identifier}/activate_console", [202]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_database_snapshot.rb0000644000004100000410000000105612464011624030021 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_snapshot_get_database_snapshot # def get_database_snapshot(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/database_snapshots/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/apply_to_firewall_policy.rb0000644000004100000410000000146012464011624030571 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Applies firewall policy to given server group # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :server_group Server Group to apply to # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#firewall_policy_apply_to_firewall_policy # def apply_to_firewall_policy(identifier, options) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/firewall_policies/#{identifier}/apply_to", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/map_cloud_ip.rb0000644000004100000410000000157312464011624026136 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Maps (or points) a cloud IP address at a server's interface or a load balancer to allow them to respond to public requests. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :destination The ID of an Interface or LoadBalancer to map the Cloud IP against # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#cloud_ip_map_cloud_ip # def map_cloud_ip(identifier, options) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/cloud_ips/#{identifier}/map", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_image.rb0000644000004100000410000000106112464011624025414 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the image. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#image_get_image # def get_image(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/images/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/unlock_resource_database_server.rb0000644000004100000410000000111612464011624032110 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_server_unlock_resource_database_server # def unlock_resource_database_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("put", "/1.0/database_servers/#{identifier}/unlock_resource", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_firewall_rule.rb0000644000004100000410000000113112464011624027164 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the firewall rule. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#firewall_rule_get_firewall_rule # def get_firewall_rule(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/firewall_rules/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/unlock_resource_database_snapshot.rb0000644000004100000410000000112612464011624032442 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_snapshot_unlock_resource_database_snapshot # def unlock_resource_database_snapshot(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("put", "/1.0/database_snapshots/#{identifier}/unlock_resource", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_api_client.rb0000644000004100000410000000143612464011624027132 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Destroy the API client. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#api_client_delete_api_client # def delete_api_client(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/api_clients/#{identifier}", [200]) end # Old format of the delete request. # # @deprecated Use +#delete_api_client+ instead # def destroy_api_client(identifier) delete_api_client(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_server_type.rb0000644000004100000410000000111712464011624026703 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the server type. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_type_get_server_type # def get_server_type(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/server_types/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_users.rb0000644000004100000410000000061412464011624025672 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of user. # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#user_list_users # def list_users wrapped_request("get", "/1.0/users", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_collaboration.rb0000644000004100000410000000160112464011624027646 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Invites the given email address to collaborate with the specified account. Existing users # will be able to accept the collaboration whilst those without a Brightbox account will be # invited to create one. # # @param [Hash] options # @option options [String] :email Email address of user to invite # @option options [String] :role Role to grant to the user. Currently only `admin` # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#collaboration_create_collaboration # def create_collaboration(options) wrapped_request("post", "/1.0/collaborations", [201], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_image.rb0000644000004100000410000000136612464011624026107 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Destroy the image. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#image_delete_image # def delete_image(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/images/#{identifier}", [202]) end # Old format of the delete request. # # @deprecated Use +#delete_image+ instead # def destroy_image(identifier) delete_image(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_user_collaborations.rb0000644000004100000410000000073012464011624030601 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists all collaborations the user is involved with # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#user_collaboration_list_user_collaborations # def list_user_collaborations wrapped_request("get", "/1.0/user/collaborations", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_applications.rb0000644000004100000410000000070512464011624027220 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Lists summary details of applications available to the user # # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#application_list_applications # def list_applications wrapped_request("get", "/1.0/applications", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_server.rb0000644000004100000410000000200012464011624026316 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Create a new server for the account based on the required disk image. # # Optionally can setup the type of server, zone to locate it, groups to join and custom metadata. # # @param [Hash] options # @option options [String] :image # @option options [String] :name Editable label # @option options [String] :server_type # @option options [String] :zone Zone in which to create new Server # @option options [String] :user_data # @option options [Array] :server_groups Array of server groups to add server to # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#server_create_server # def create_server(options) wrapped_request("post", "/1.0/servers", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_server_group.rb0000644000004100000410000000147412464011624027547 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Destroy the server group if not in use. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_group_delete_server_group # def delete_server_group(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/server_groups/#{identifier}", [202]) end # Old format of the delete request. # # @deprecated Use +#delete_server_group+ instead # def destroy_server_group(identifier) delete_server_group(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/snapshot_server.rb0000644000004100000410000000232012464011624026717 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Will issue a request to snapshot the Server # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [Boolean] :return_link Return the Link header as a second return value # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_snapshot_server # def snapshot_server(identifier, options = {}) return nil if identifier.nil? || identifier == "" method = "POST" path = "/1.0/servers/#{identifier}/snapshot" expected = [202] if options[:return_link] request_parameters = { :method => method, :path => path, :expects => expected } response = request(request_parameters) data = Fog::JSON.decode(response.body) image_id = Fog::Brightbox::LinkHelper.new(response.headers["Link"]).identifier return data, image_id else wrapped_request(method, path, expected) end end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_image.rb0000644000004100000410000000203012464011624026114 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some details of the image. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name # @option options [String] :username # @option options [String] :arch # @option options [String] :status # @option options [Boolean] :public # @option options [Boolean] :compatibility_mode # @option options [String] :description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#image_update_image # def update_image(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/images/#{identifier}", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/create_load_balancer.rb0000644000004100000410000000302412464011624027565 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Create a new load balancer for the account. # # @param [Hash] options # @option options [String] :name Editable label # @option options [Integer] :buffer_size Buffer size of load balancer. Default is 4096. # @option options [Array] :nodes Array of Node parameters # @option options [String] :policy Method of Load balancing to use # @option options [String] :certificate_pem A X509 SSL certificate in PEM format. Must be included along with 'certificate_key'. If intermediate certificates are required they should be concatenated after the main certificate # @option options [String] :certificate_key The RSA private key used to sign the certificate in PEM format. Must be included along with 'certificate_pem' # @option options [Array] :listeners What port to listen on, port to pass through to and protocol (tcp, http or http+ws) of listener. Timeout is optional and specified in milliseconds (default is 50000). # @option options [String] :healthcheck Healthcheck options - only "port" and "type" required # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_create_load_balancer # def create_load_balancer(options) wrapped_request("post", "/1.0/load_balancers", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_api_client.rb0000644000004100000410000000111212464011624026436 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the API client. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#api_client_get_api_client # def get_api_client(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/api_clients/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/list_accounts.rb0000644000004100000410000000054512464011624026353 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#account_list_accounts # def list_accounts wrapped_request("get", "/1.0/accounts", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/reboot_server.rb0000644000004100000410000000115012464011624026352 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Shuts down and resets the server without disconnecting the console. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#server_reboot_server # def reboot_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/servers/#{identifier}/reboot", [202]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_authenticated_user.rb0000644000004100000410000000052212464011624030213 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Requests details about authenticated user from the API # # @return [Hash] The JSON response parsed to a Hash # def get_authenticated_user wrapped_request("get", "/1.0/user", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/lock_resource_database_server.rb0000644000004100000410000000111012464011624031537 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_server_lock_resource_database_server # def lock_resource_database_server(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("put", "/1.0/database_servers/#{identifier}/lock_resource", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_server_group.rb0000644000004100000410000000160412464011624027562 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some details of the server group. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name Editable user label # @option options [String] :description Editable user description # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#server_group_update_server_group # def update_server_group(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/server_groups/#{identifier}", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_user.rb0000644000004100000410000000210412464011624026012 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some details of your user profile. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name # @option options [String] :email_address # @option options [String] :ssh_key # @option options [String] :password A password string that conforms to the minimum requirements # @option options [String] :password_confirmation A password string that conforms to the minimum requirements # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#user_update_user # def update_user(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/users/#{identifier}", [200], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_application.rb0000644000004100000410000000111712464011624026637 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the application. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#application_get_application # def get_application(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/applications/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/move_servers_server_group.rb0000644000004100000410000000247612464011624031027 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Removes a number of server from the server group and adds them to another server group given in parameters. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [Array] :servers Array of Hashes containing # +{"server" => server_id}+ for each server to remove # @option options [String] :destination ServerGroup to move servers to # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#server_group_move_servers_server_group # # @example # options = { # :destination => "grp-67890", # :servers => [ # {"server" => "srv-abcde"}, # {"server" => "srv-fghij"} # ] # } # Compute[:brightbox].remove_servers_server_group "grp-12345", options # def move_servers_server_group(identifier, options) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/server_groups/#{identifier}/move_servers", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/unlock_resource_load_balancer.rb0000644000004100000410000000110612464011624031523 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_unlock_resource_load_balancer # def unlock_resource_load_balancer(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("put", "/1.0/load_balancers/#{identifier}/unlock_resource", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_collaboration.rb0000644000004100000410000000150212464011624027645 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Cancels or completes the collaboration # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#collaboration_delete_collaboration # def delete_collaboration(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/collaborations/#{identifier}", [200]) end # Old format of the delete request. # # @deprecated Use +#delete_collaboration+ instead # def destroy_collaboration(identifier) delete_collaboration(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_firewall_policy.rb0000644000004100000410000000113612464011624027521 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get details of the firewall policy # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#firewall_policy_get_firewall_policy # def get_firewall_policy(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/firewall_policies/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_account.rb0000644000004100000410000000167712464011624026003 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the account. # # @overload get_account(identifier) # @param [String] identifier Unique reference to identify the resource # # @overload get_account() # @deprecated Use {Fog::Compute::Brightbox::Real#get_scoped_account} instead # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#account_get_account # def get_account(identifier = nil) if identifier.nil? || identifier.empty? Fog::Logger.deprecation("get_account() without a parameter is deprecated, use get_scoped_account instead [light_black](#{caller.first})[/]") get_scoped_account else wrapped_request("get", "/1.0/accounts/#{identifier}", [200]) end end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/update_load_balancer.rb0000644000004100000410000000335512464011624027613 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Update some details of the load balancer. # # @param [String] identifier Unique reference to identify the resource # @param [Hash] options # @option options [String] :name Editable label # @option options [Integer] :buffer_size Buffer size of load balancer. Default is 4096. # @option options [Array] :nodes Array of Node parameters # @option options [String] :policy Method of Load balancing to use # @option options [String] :certificate_pem A X509 SSL certificate in PEM format. Must be included along with 'certificate_key'. If intermediate certificates are required they should be concatenated after the main certificate # @option options [String] :certificate_key The RSA private key used to sign the certificate in PEM format. Must be included along with 'certificate_pem' # @option options [Array] :listeners What port to listen on, port to pass through to and protocol (tcp, http or http+ws) of listener. Timeout is optional and specified in milliseconds (default is 50000). # @option options [String] :healthcheck Healthcheck options - only "port" and "type" required # # @return [Hash] if successful Hash version of JSON object # @return [NilClass] if no options were passed # # @see https://api.gb1.brightbox.com/1.0/#load_balancer_update_load_balancer # def update_load_balancer(identifier, options) return nil if identifier.nil? || identifier == "" return nil if options.empty? || options.nil? wrapped_request("put", "/1.0/load_balancers/#{identifier}", [202], options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb0000644000004100000410000000125712464011624026500 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Unmaps a cloud IP address from its current destination making it available to remap. This remains in the account's pool of addresses. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#cloud_ip_unmap_cloud_ip # def unmap_cloud_ip(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/cloud_ips/#{identifier}/unmap", [202]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/lock_resource_database_snapshot.rb0000644000004100000410000000112012464011624032071 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#database_snapshot_lock_resource_database_snapshot # def lock_resource_database_snapshot(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("put", "/1.0/database_snapshots/#{identifier}/lock_resource", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/reset_secret_application.rb0000644000004100000410000000121612464011624030547 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Resets the secret used by the application to a new generated value. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#application_reset_secret_application # def reset_secret_application(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/applications/#{identifier}/reset_secret", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/get_interface.rb0000644000004100000410000000110512464011624026271 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Get full details of the interface. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#interface_get_interface # def get_interface(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("get", "/1.0/interfaces/#{identifier}", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_firewall_rule.rb0000644000004100000410000000146612464011624027662 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Destroy the firewall rule. # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#firewall_rule_delete_firewall_rule # def delete_firewall_rule(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/firewall_rules/#{identifier}", [202]) end # Old format of the delete request. # # @deprecated Use +#delete_firewall_rule+ instead # def destroy_firewall_rule(identifier) delete_firewall_rule(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/delete_user_collaboration.rb0000644000004100000410000000155012464011624030706 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Ends an existing 'accepted' collaboration # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#user_collaboration_delete_user_collaboration # def delete_user_collaboration(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("delete", "/1.0/user/collaborations/#{identifier}", [200]) end # Old format of the delete request. # # @deprecated Use +#delete_user_collaboration+ instead # def destroy_user_collaboration(identifier) delete_user_collaboration(identifier) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/requests/compute/resend_collaboration.rb0000644000004100000410000000116112464011624027664 0ustar www-datawww-datamodule Fog module Compute class Brightbox class Real # Resends the invitation email to the collaborator # # @param [String] identifier Unique reference to identify the resource # # @return [Hash] if successful Hash version of JSON object # # @see https://api.gb1.brightbox.com/1.0/#collaboration_resend_collaboration # def resend_collaboration(identifier) return nil if identifier.nil? || identifier == "" wrapped_request("post", "/1.0/collaborations/#{identifier}/resend", [200]) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/version.rb0000644000004100000410000000007612464011624021636 0ustar www-datawww-datamodule Fog module Brightbox VERSION = "0.7.1" end end fog-brightbox-0.7.1/lib/fog/brightbox/config.rb0000644000004100000410000001735112464011624021422 0ustar www-datawww-datarequire "fog/brightbox/oauth2" module Fog module Brightbox # The {Fog::Brightbox::Config} class is designed to encapsulate a group of settings for reuse # between Brightbox services. The same config can be used for any service. # # The config also holds the latest set of access tokens which when shared means when one service # is told a token has expired then another will not retry it. # class Config attr_writer :storage_management_url # Creates a new set of configuration settings based on the options provided. # # @param [Hash] options The configuration settings # @option options [String] :brightbox_access_token # Set to use a cached OAuth access token to avoid having to request new access rights. # @option options [String] :brightbox_account # Set to specify the account to scope requests to if relevant. API clients are limited to # their owning accounts but users can access any account they collaborate on. # @option options [String] :brightbox_api_url (https://api.gb1.brightbox.com) # Set an alternative API endpoint to send requests to. # @option options [String] :brightbox_auth_url (https://api.gb1.brightbox.com) # Set an alternative OAuth authentication endpoint to send requests to. # @option options [String] :brightbox_client_id # Set to specify the client identifier to use for requests. Either +cli-12345+ or # +app-12345+ are suitable settings. # @option options [String] :brightbox_default_image # Set to specify a preferred image to use by default in the Compute service. # @option options [String] :brightbox_password # Set to specify your user's password to authenticate yourself. This is independent of the # client used to access the API. # @option options [String] :brightbox_refresh_token # Set to use a cached OAuth refresh token to avoid having to request new access rights. # @option options [String] :brightbox_secret # Set to specify the client secret to use for requests. # @option options [String] :brightbox_token_management (true) # Set to specify if the service should handle expired tokens or raise an error instead. # @option options [String] :brightbox_username # Set to specify your user account. Either user identifier (+usr-12345+) or email address # may be used. # @option options [String] :connection_options ({}) # Set to pass options through to the HTTP connection. # @option options [Boolean] :persistent (false) # Set to specify if the HTTP connection be persistent # # @example Use Fog.credentials # # Assuming credentials are setup to return Brightbox settings and not other providers! # @config = Fog::Brightbox::Config.new(Fog.credentials) # def initialize(options = {}) @options = options end # @return [OAuth2::CredentialSet] def credentials @credentials ||= OAuth2::CredentialSet.new(client_id, client_secret, :username => username, :password => password, :access_token => cached_access_token, :refresh_token => cached_refresh_token ) end # @return [Boolean] def user_credentials? credentials.user_details? end # Can this be used to configure services? Yes, yes it can. # # @return [true] def config_service? true end def to_hash @options end # @return [URI::HTTPS] A URI object for the authentication endpoint def auth_url URI.parse(@options.fetch(:brightbox_auth_url, "https://api.gb1.brightbox.com")) end # @return [URI::HTTPS] A URI object for the main API/compute service endpoint def compute_url URI.parse(@options.fetch(:brightbox_api_url, "https://api.gb1.brightbox.com")) end alias_method :api_url, :compute_url def storage_url URI.parse(@options[:brightbox_storage_url] || "https://orbit.brightbox.com") end def storage_management_url @storage_management_url ||= if @options.key?(:brightbox_storage_management_url) URI.parse(@options[:brightbox_storage_management_url]) else nil end end # @return [String] The configured identifier of the API client or user application. def client_id @options[:brightbox_client_id] end # @return [String] The configured secret to use to identify the client. def client_secret @options[:brightbox_secret] end # @return [String] The configured email or user identified to use when accessing the API. def username @options[:brightbox_username] end # @return [String] The configured password to use to identify the user. def password @options[:brightbox_password] end # @return [String] The configured account identifier to scope API requests by. def account @current_account ||= @options[:brightbox_account] end # This changes the scoped account from the originally configured one to another. # # @return [String] The new account identifier used to scope API requests by. def change_account(new_account) @current_account = new_account end # Sets the scoped account back to originally configured one. # # @return [String] The configured account identifier to scope API requests by. def reset_account @current_account = @options[:brightbox_account] end def connection_options # These are pretty much passed through to the requests as is. @options.fetch(:connection_options, {}) end def connection_persistent? @options.fetch(:persistent, false) end def cached_access_token @options[:brightbox_access_token] end def latest_access_token credentials.access_token end def cached_refresh_token @options[:brightbox_refresh_token] end # This is the current, most up to date refresh token. def latest_refresh_token credentials.refresh_token end def must_authenticate? !credentials.access_token? end # Allows classes sharing to mark the tokens as invalid in response to API status codes. def expire_tokens! update_tokens(nil) end # @param [String] access_token The new access token to use # @param [String] refresh_token The new refresh token to use def update_tokens(access_token, refresh_token = nil, expires_in = nil) credentials.update_tokens(access_token, refresh_token, expires_in) end def managed_tokens? @options.fetch(:brightbox_token_management, true) end def default_image_id @options.fetch(:brightbox_default_image, nil) end def latest_token @options[:brightbox_access_token] end def service_type @options[:brightbox_service_type] || "object-store" end def service_name @options[:brightbox_service_name] end def region @options[:brightbox_region] end def tenant @options[:brightbox_tenant] end def storage_connection_options @options[:connection_options] || {} end def storage_temp_key @options[:brightbox_temp_url_key] end end end end fog-brightbox-0.7.1/lib/fog/brightbox/core.rb0000644000004100000410000000031212464011624021072 0ustar www-datawww-datarequire "fog/core" require "fog/json" require "fog/brightbox/config" module Fog module Brightbox extend Fog::Provider service(:compute, "Compute") service(:storage, "Storage") end end fog-brightbox-0.7.1/lib/fog/brightbox/compute/0000755000004100000410000000000012464011624021275 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/brightbox/compute/image_selector.rb0000644000004100000410000000246712464011624024615 0ustar www-datawww-datamodule Fog module Brightbox module Compute # # This selects the preferred image to use based on a number of # conditions # class ImageSelector # Prepares a selector with the API output # # @param [Array] images hash matching API output for {Fog::Compute::Brightbox#list_images} # def initialize(images) @images = images end # Returns current identifier of the latest version of Ubuntu # # The order of preference is: # * Only Official Brightbox images # * Only Ubuntu images # * Latest by name (alphanumeric sort) # * Latest by creation date # # @note This performs a live query against the API # # @return [String] if image matches containing the identifier # @return [NilClass] if no image matches # def latest_ubuntu @images.select do |img| img["official"] == true && img["arch"] == "i686" && img["name"] =~ /ubuntu/i end.sort do |a, b| # Reverse sort so "raring" > "precise" and "13.10" > "13.04" b["name"].downcase <=> a["name"].downcase end.first["id"] rescue nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/compute/shared.rb0000644000004100000410000001734612464011624023103 0ustar www-datawww-datarequire "fog/brightbox/oauth2" module Fog module Brightbox module Compute # The Shared module consists of code that was duplicated between the Real # and Mock implementations. # module Shared include Fog::Brightbox::OAuth2 attr_writer :scoped_account API_URL = "https://api.gb1.brightbox.com/" # Creates a new instance of the Brightbox Compute service # # @note If you create service using just a refresh token when it # expires the service will no longer be able to authenticate. # # @see Fog::Brightbox::Config#initialize Config object for possible configuration options # # @param [Brightbox::Config, Hash] config # Any configuration to be used for this service. This ideally should be in the newer form # of a {Brightbox::Config} object but may be a Hash. # def initialize(config) if config.respond_to?(:config_service?) && config.config_service? @config = config else @config = Fog::Brightbox::Config.new(config) end @config = Fog::Brightbox::Compute::Config.new(@config) # Currently authentication and api endpoints are the same but may change @auth_url = @config.auth_url.to_s @auth_connection = Fog::Core::Connection.new(@auth_url) @api_url = @config.compute_url.to_s @connection_options = @config.connection_options @persistent = @config.connection_persistent? @connection = Fog::Core::Connection.new(@api_url, @persistent, @connection_options) # Authentication options client_id = @config.client_id client_secret = @config.client_secret username = @config.username password = @config.password @configured_account = @config.account # Request account can be changed at anytime and changes behaviour of future requests @scoped_account = @configured_account credential_options = { :username => username, :password => password } @credentials = CredentialSet.new(client_id, client_secret, credential_options) # If existing tokens have been cached, allow continued use of them in the service @credentials.update_tokens(@config.cached_access_token, @config.cached_refresh_token) @token_management = @config.managed_tokens? end # This returns the account identifier that the request should be scoped by # based on the options passed to the request and current configuration # # @param [String] options_account Any identifier passed into the request # # @return [String, nil] The account identifier to scope the request to or nil def scoped_account(options_account = nil) [options_account, @scoped_account].compact.first end # Resets the scoped account back to intially configured one def scoped_account_reset @scoped_account = @configured_account end # Returns the scoped account being used for requests # # * For API clients this is the owning account # * For User applications this is the account specified by either +account_id+ # option on the service or the +brightbox_account+ setting in your configuration # # @return [Fog::Compute::Brightbox::Account] # def account account_data = get_scoped_account.merge(:service => self) Fog::Compute::Brightbox::Account.new(account_data) end # Returns true if authentication is being performed as a user # @return [Boolean] def authenticating_as_user? @credentials.user_details? end # Returns true if an access token is set # @return [Boolean] def access_token_available? !! @credentials.access_token end # Returns the current access token or nil # @return [String,nil] def access_token @credentials.access_token end # Returns the current refresh token or nil # @return [String,nil] def refresh_token @credentials.refresh_token end # Returns the current token expiry time in seconds or nil # @return [Number,nil] def expires_in @credentials.expires_in end # Requests a new access token # # @return [String] New access token def get_access_token begin get_access_token! rescue Excon::Errors::Unauthorized, Excon::Errors::BadRequest @credentials.update_tokens(nil, nil) end @credentials.access_token end # Requests a new access token and raises if there is a problem # # @return [String] New access token # @raise [Excon::Errors::BadRequest] The credentials are expired or incorrect # def get_access_token! response = request_access_token(@auth_connection, @credentials) update_credentials_from_response(@credentials, response) @credentials.access_token end # Returns an identifier for the default image for use # # Currently tries to find the latest version of Ubuntu (i686) from # Brightbox. # # Highly recommended that you actually select the image you want to run # on your servers yourself! # # @return [String] if image is found, returns the identifier # @return [NilClass] if no image is found or an error occurs # def default_image return @default_image_id unless @default_image_id.nil? @default_image_id = @config.default_image_id || select_default_image end private # This makes a request of the API based on the configured setting for # token management. # # @param [Hash] options Excon compatible options # @see https://github.com/geemus/excon/blob/master/lib/excon/connection.rb # # @return [Hash] Data of response body # def make_request(options) if @token_management managed_token_request(options) else authenticated_request(options) end end # This request checks for access tokens and will ask for a new one if # it receives Unauthorized from the API before repeating the request # # @param [Hash] options Excon compatible options # # @return [Excon::Response] def managed_token_request(options) get_access_token unless access_token_available? authenticated_request(options) rescue Excon::Errors::Unauthorized get_access_token authenticated_request(options) end # This request makes an authenticated request of the API using currently # setup credentials. # # @param [Hash] options Excon compatible options # # @see https://github.com/geemus/excon/blob/master/lib/excon/connection.rb # # @return [Excon::Response] def authenticated_request(options) headers = options[:headers] || {} headers.merge!("Authorization" => "OAuth #{@credentials.access_token}", "Content-Type" => "application/json") options[:headers] = headers # TODO: This is just a wrapper around a call to Excon::Connection#request # so can be extracted from Compute by passing in the connection, # credentials and options @connection.request(options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/compute/resource_locking.rb0000644000004100000410000000125512464011624025162 0ustar www-datawww-datamodule Fog module Brightbox module Compute module ResourceLocking def locked? if attributes.key?("locked") || attributes.key?(:locked) attributes["locked"] || attributes[:locked] || false else false end end def lock! locking_request(:lock) end def unlock! locking_request(:unlock) end private def locking_request(lock_setting) requires :identity data = service.send(:"#{lock_setting}_resource_#{resource_name}", identity) merge_attributes(data) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/compute/config.rb0000644000004100000410000000072012464011624023066 0ustar www-datawww-datarequire "delegate" module Fog module Brightbox module Compute class Config < SimpleDelegator def initialize(config) super @config = config raise ArgumentError unless required_args_available? end private def required_args_available? return false unless @config.client_id return false unless @config.client_secret true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/0000755000004100000410000000000012464011624021104 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/brightbox/models/storage/0000755000004100000410000000000012464011624022550 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/brightbox/models/storage/directory.rb0000644000004100000410000000232312464011624025101 0ustar www-datawww-datarequire "fog/core/model" require "fog/brightbox/models/storage/files" module Fog module Storage class Brightbox class Directory < Fog::Model identity :key, :aliases => "name" attribute :bytes, :aliases => "X-Container-Bytes-Used" attribute :count, :aliases => "X-Container-Object-Count" attribute :read_permissions, :aliases => "X-Container-Read" attribute :write_permissions, :aliases => "X-Container-Write" def destroy requires :key service.delete_container(key) true rescue Excon::Errors::NotFound false end def files @files ||= begin Fog::Storage::Brightbox::Files.new( :directory => self, :service => service ) end end attr_writer :public def public_url # raise NotImplementedError "" end def save requires :key options = { "read_permissions" => read_permissions, "write_permissions" => write_permissions } service.put_container(key, options) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/storage/files.rb0000644000004100000410000000536712464011624024212 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/storage/file" module Fog module Storage class Brightbox class Files < Fog::Collection attribute :directory attribute :limit attribute :marker attribute :path attribute :prefix model Fog::Storage::Brightbox::File def all(options = {}) requires :directory options = { "limit" => limit, "marker" => marker, "path" => path, "prefix" => prefix }.merge!(options) merge_attributes(options) parent = directory.collection.get( directory.key, options ) if parent load(parent.files.map { |file| file.attributes }) else nil end end alias_method :each_file_this_page, :each def each if !block_given? self else subset = dup.all subset.each_file_this_page { |f| yield f } while subset.length == (subset.limit || 10_000) subset = subset.all(:marker => subset.last.key) subset.each_file_this_page { |f| yield f } end self end end def get(key, &block) requires :directory data = service.get_object(directory.key, key, &block) file_data = data.headers.merge( :body => data.body, :key => key ) new(file_data) rescue Fog::Storage::Brightbox::NotFound nil end def get_url(key) requires :directory if directory.public_url "#{directory.public_url}/#{Fog::Storage::Brightbox.escape(key, "/")}" end end def get_http_url(key, expires, options = {}) requires :directory service.get_object_http_url(directory.key, key, expires, options) end def get_https_url(key, expires, options = {}) requires :directory service.get_object_https_url(directory.key, key, expires, options) end def head(key, _options = {}) requires :directory data = service.head_object(directory.key, key) file_data = data.headers.merge( :key => key ) new(file_data) rescue Fog::Storage::Brightbox::NotFound nil end def new(attributes = {}) requires :directory super({ :directory => directory }.merge!(attributes)) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/storage/directories.rb0000644000004100000410000000210112464011624025403 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/storage/directory" module Fog module Storage class Brightbox class Directories < Fog::Collection model Fog::Storage::Brightbox::Directory HEADER_ATTRIBUTES = %w(X-Container-Bytes-Used X-Container-Object-Count X-Container-Read X-Container-Write) def all data = service.get_containers.body load(data) end def get(key, options = {}) data = service.get_container(key, options) directory = new(:key => key) data.headers.each do |header, value| if HEADER_ATTRIBUTES.include?(header) directory.merge_attributes(header => value) end end directory.files.merge_attributes(options) directory.files.instance_variable_set(:@loaded, true) data.body.each do |file| directory.files << directory.files.new(file) end directory rescue Fog::Storage::Brightbox::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/storage/file.rb0000644000004100000410000001166412464011624024024 0ustar www-datawww-datarequire "fog/core/model" module Fog module Storage class Brightbox class File < Fog::Model identity :key, :aliases => "name" attribute :content_length, :aliases => %w(bytes Content-Length), :type => :integer attribute :content_type, :aliases => %w(content_type Content-Type) attribute :content_disposition, :aliases => %w(content_disposition Content-Disposition) attribute :etag, :aliases => %w(hash Etag) attribute :last_modified, :aliases => %w(last_modified Last-Modified), :type => :time attribute :access_control_allow_origin, :aliases => ["Access-Control-Allow-Origin"] attribute :origin, :aliases => ["Origin"] def body attributes[:body] ||= if last_modified collection.get(identity).body else "" end end def body=(new_body) attributes[:body] = new_body end attr_reader :directory def copy(target_directory_key, target_file_key, options = {}) requires :directory, :key options["Content-Type"] ||= content_type if content_type options["Access-Control-Allow-Origin"] ||= access_control_allow_origin if access_control_allow_origin options["Origin"] ||= origin if origin service.copy_object(directory.key, key, target_directory_key, target_file_key, options) target_directory = service.directories.new(:key => target_directory_key) target_directory.files.get(target_file_key) end def destroy requires :directory, :key service.delete_object(directory.key, key) true end def metadata @metadata ||= headers_to_metadata end def owner=(new_owner) if new_owner attributes[:owner] = { :display_name => new_owner["DisplayName"], :id => new_owner["ID"] } end end def public=(new_public) new_public end # Get a url for file. # # required attributes: key # # @param expires [String] number of seconds (since 1970-01-01 00:00) before url expires # @param options [Hash] # @return [String] url # def url(expires, options = {}) requires :directory, :key service.create_temp_url(directory.key, key, expires, "GET", options) end def public_url requires :key collection.get_url(key) end def save(options = {}) requires :body, :directory, :key options["Content-Type"] = content_type if content_type options["Content-Disposition"] = content_disposition if content_disposition options["Access-Control-Allow-Origin"] = access_control_allow_origin if access_control_allow_origin options["Origin"] = origin if origin options.merge!(metadata_to_headers) data = service.put_object(directory.key, key, body, options) update_attributes_from(data) refresh_metadata self.content_length = Fog::Storage.get_body_size(body) self.content_type ||= Fog::Storage.get_content_type(body) true end private attr_writer :directory def refresh_metadata metadata.reject! { |_k, v| v.nil? } end def headers_to_metadata key_map = key_mapping Hash[metadata_attributes.map { |k, v| [key_map[k], v] }] end def key_mapping key_map = metadata_attributes key_map.each_pair { |k, _v| key_map[k] = header_to_key(k) } end def header_to_key(opt) opt.gsub(metadata_prefix, "").split("-").map { |k| k[0, 1].downcase + k[1..-1] }.join("_").to_sym end def metadata_to_headers header_map = header_mapping Hash[metadata.map { |k, v| [header_map[k], v] }] end def header_mapping header_map = metadata.dup header_map.each_pair { |k, _v| header_map[k] = key_to_header(k) } end def key_to_header(key) metadata_prefix + key.to_s.split(/[-_]/).map(&:capitalize).join("-") end def metadata_attributes if last_modified headers = service.head_object(directory.key, key).headers headers.reject! { |k, _v| !metadata_attribute?(k) } else {} end end def metadata_attribute?(key) key.to_s =~ /^#{metadata_prefix}/ end def metadata_prefix "X-Object-Meta-" end def update_attributes_from(data) merge_attributes(data.headers.reject { |key, _value| %w(Content-Length Content-Type).include?(key) }) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/0000755000004100000410000000000012464011624022560 5ustar www-datawww-datafog-brightbox-0.7.1/lib/fog/brightbox/models/compute/database_type.rb0000644000004100000410000000055212464011624025714 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class DatabaseType < Fog::Brightbox::Model identity :id attribute :url attribute :resource_type attribute :name attribute :description attribute :disk, :aliases => "disk_size" attribute :ram end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/application.rb0000644000004100000410000000111312464011624025404 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class Application < Fog::Brightbox::Model identity :id attribute :url attribute :name attribute :secret def save raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted? options = { :name => name }.delete_if { |_k, v| v.nil? || v == "" } data = service.create_application(options) merge_attributes(data) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/database_types.rb0000644000004100000410000000101012464011624026065 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/database_type" module Fog module Compute class Brightbox class DatabaseTypes < Fog::Collection model Fog::Compute::Brightbox::DatabaseType def all data = service.list_database_types load(data) end def get(identifier) data = service.get_database_type(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/database_servers.rb0000644000004100000410000000102212464011624026415 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/database_server" module Fog module Compute class Brightbox class DatabaseServers < Fog::Collection model Fog::Compute::Brightbox::DatabaseServer def all data = service.list_database_servers load(data) end def get(identifier) data = service.get_database_server(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/api_client.rb0000644000004100000410000000204112464011624025211 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class ApiClient < Fog::Brightbox::Model identity :id attribute :name attribute :description attribute :secret attribute :revoked_at, :type => :time attribute :permissions_group attribute :account_id def save raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted? options = { :name => name, :description => description, :permissions_group => permissions_group }.delete_if { |_k, v| v.nil? || v == "" } data = service.create_api_client(options) merge_attributes(data) true end def destroy requires :identity service.destroy_api_client(identity) true end def reset_secret requires :identity service.reset_secret_api_client(identity) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/images.rb0000644000004100000410000000074212464011624024355 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/image" module Fog module Compute class Brightbox class Images < Fog::Collection model Fog::Compute::Brightbox::Image def all data = service.list_images load(data) end def get(identifier) data = service.get_image(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/zones.rb0000644000004100000410000000103112464011624024236 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/zone" module Fog module Compute class Brightbox class Zones < Fog::Collection model Fog::Compute::Brightbox::Zone def all data = service.list_zones load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" data = service.get_zone(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/servers.rb0000644000004100000410000000341612464011624024602 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/server" module Fog module Compute class Brightbox class Servers < Fog::Collection model Fog::Compute::Brightbox::Server def all data = service.list_servers load(data) end # Creates a server and maps an Cloud IP # # By default the public SSH key you have registered with # Brightbox is already made available in an AWS compatible # metdata service. # # @todo Support uploading of arbitary SSH keys # # @param [Hash] options # @option options [String] name Name for the server # @option options [String] flavor_id Identifier for virtual hardware type to request # @option options [String] image_id Identifier for image to use when creating # @option options [String] zone_id Identifer for preferred zone to locate server in # @option options [Array] server_groups List of group identifiers for the server to join # # @return Fog::Compute::Brightbox::Server # def bootstrap(options = {}) server = create(options) # Ensure server is now available server.wait_for { ready? } # To get a public IP address we need to map a cloud IP address cip = service.cloud_ips.allocate cip.map(server) cip.wait_for { mapped? } # Reload so the public IP is now available server.reload end def get(identifier) return nil if identifier.nil? || identifier == "" data = service.get_server(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/accounts.rb0000644000004100000410000000105012464011624024720 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/account" module Fog module Compute class Brightbox class Accounts < Fog::Collection model Fog::Compute::Brightbox::Account def all data = service.list_accounts load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" data = service.get_account(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/database_server.rb0000644000004100000410000000552712464011624026250 0ustar www-datawww-datarequire "fog/brightbox/model" require "fog/brightbox/compute/resource_locking" module Fog module Compute class Brightbox class DatabaseServer < Fog::Brightbox::Model include Fog::Brightbox::Compute::ResourceLocking identity :id attribute :url attribute :resource_type attribute :name attribute :description attribute :state, :aliases => "status" attribute :admin_username attribute :admin_password attribute :database_engine attribute :database_version attribute :maintenance_weekday attribute :maintenance_hour attribute :created_at, :type => :time attribute :updated_at, :type => :time attribute :deleted_at, :type => :time attribute :allow_access attribute :flavor_id, "alias" => "database_server_type", :squash => "id" attribute :zone_id, "alias" => "zone", :squash => "id" attribute :cloud_ips def save options = { :name => name, :description => description } options[:allow_access] = allow_access if allow_access # These may be nil which sets them to default values upstream # TODO: Dirty track the values so we don't send them when already nil options[:maintenance_weekday] = maintenance_weekday options[:maintenance_hour] = maintenance_hour if persisted? data = update_database_server(options) else options[:engine] = database_engine if database_engine options[:version] = database_version if database_version options[:database_type] = flavor_id if flavor_id options[:zone] = zone_id if zone_id data = create_database_server(options) end merge_attributes(data) true end def ready? state == "active" end def snapshot(return_snapshot = false) requires :identity response, snapshot_id = service.snapshot_database_server(identity, :return_link => return_snapshot) merge_attributes(response) if return_snapshot service.database_snapshots.get(snapshot_id) else true end end def destroy requires :identity merge_attributes(service.destroy_database_server(identity)) true end def reset_password requires :identity merge_attributes(service.reset_password_database_server(identity)) true end private def create_database_server(options) service.create_database_server(options) end def update_database_server(options) service.update_database_server(identity, options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/cloud_ip.rb0000644000004100000410000000353512464011624024711 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class CloudIp < Fog::Brightbox::Model identity :id attribute :url attribute :resource_type attribute :name attribute :status attribute :description attribute :reverse_dns attribute :public_ip # Links - to be replaced attribute :account_id, :aliases => "account", :squash => "id" attribute :interface_id, :aliases => "interface", :squash => "id" attribute :server_id, :aliases => "server", :squash => "id" attribute :load_balancer, :alias => "load_balancer", :squash => "id" attribute :server_group, :alias => "server_group", :squash => "id" attribute :database_server, :alias => "database_server", :squash => "id" attribute :port_translators attribute :name # Attempt to map or point the Cloud IP to the destination resource. # # @param [Object] destination # def map(destination) requires :identity if destination.respond_to?(:mapping_identity) final_destination = destination.mapping_identity elsif destination.respond_to?(:identity) final_destination = destination.identity else final_destination = destination end service.map_cloud_ip(identity, :destination => final_destination) end def mapped? status == "mapped" end def unmap requires :identity service.unmap_cloud_ip(identity) end def destroy requires :identity service.destroy_cloud_ip(identity) end def destination_id server_id || load_balancer || server_group || database_server || interface_id end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/firewall_policy.rb0000644000004100000410000000321112464011624026266 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class FirewallPolicy < Fog::Brightbox::Model identity :id attribute :url attribute :resource_type attribute :name attribute :description attribute :default attribute :server_group_id, :aliases => "server_group", :squash => "id" attribute :created_at, :type => :time attribute :rules # Sticking with existing Fog behaviour, save does not update but creates a new resource def save raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted? options = { :server_group => server_group_id, :name => name, :description => description }.delete_if { |_k, v| v.nil? || v == "" } data = service.create_firewall_policy(options) merge_attributes(data) true end def apply_to(server_group_id) requires :identity options = { :server_group => server_group_id } data = service.apply_to_firewall_policy(identity, options) merge_attributes(data) true end def remove(server_group_id) requires :identity options = { :server_group => server_group_id } data = service.remove_firewall_policy(identity, options) merge_attributes(data) true end def destroy requires :identity service.destroy_firewall_policy(identity) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/load_balancer.rb0000644000004100000410000000710212464011624025653 0ustar www-datawww-datarequire "fog/brightbox/model" require "fog/brightbox/compute/resource_locking" module Fog module Compute class Brightbox class LoadBalancer < Fog::Brightbox::Model include Fog::Brightbox::Compute::ResourceLocking identity :id attribute :url attribute :resource_type attribute :name attribute :status attribute :buffer_size attribute :policy attribute :nodes attribute :healthcheck attribute :listeners # These SSL attributes act only as setters. You can not read certs or keys via the API attribute :certificate_pem attribute :certificate_private_key # These SSL attributes act only as getters for metadata attribute :certificate_valid_from attribute :certificate_expires_at attribute :certificate_issuer attribute :certificate_subject attribute :certificate_enable_ssl3 # Times attribute :created_at, :type => :time attribute :deleted_at, :type => :time # Links - to be replaced attribute :account attribute :server attribute :cloud_ip def ready? status == "active" end def save raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted? requires :nodes, :listeners, :healthcheck options = { :nodes => nodes, :listeners => listeners, :healthcheck => healthcheck, :policy => policy, :name => name, :buffer_size => buffer_size, :certificate_pem => certificate_pem, :certificate_private_key => certificate_private_key, :sslv3 => ssl3? }.delete_if { |_k, v| v.nil? || v == "" } data = service.create_load_balancer(options) merge_attributes(data) true end def destroy requires :identity service.destroy_load_balancer(identity) true end # SSL cert metadata for expiration of certificate def certificate_expires_at attributes[:certificate_expires_at] end # SSL cert metadata for subject def certificate_subject attributes[:certificate_subject] end # Sets the certificate metadata from the JSON object that contains it. # # It is used by fog's attribute setting and should not be used for attempting to set a # certificate on a load balancer. # # @private def certificate=(cert_metadata) if cert_metadata attributes[:certificate_valid_from] = time_or_original(cert_metadata["valid_from"]) attributes[:certificate_expires_at] = time_or_original(cert_metadata["expires_at"]) attributes[:certificate_issuer] = cert_metadata["issuer"] attributes[:certificate_subject] = cert_metadata["subject"] attributes[:certificate_enable_ssl3] = cert_metadata["sslv3"] else attributes[:certificate_valid_from] = nil attributes[:certificate_expires_at] = nil attributes[:certificate_issuer] = nil attributes[:certificate_subject] = nil attributes[:certificate_enable_ssl3] = nil end end def ssl3? !!attributes[:certificate_enable_ssl3] end private def time_or_original(value) Time.parse(value) rescue TypeError, ArgumentError value end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/database_snapshot.rb0000644000004100000410000000235612464011624026576 0ustar www-datawww-datarequire "fog/brightbox/model" require "fog/brightbox/compute/resource_locking" module Fog module Compute class Brightbox class DatabaseSnapshot < Fog::Brightbox::Model include Fog::Brightbox::Compute::ResourceLocking identity :id attribute :url attribute :resource_type attribute :name attribute :description attribute :state, :aliases => "status" attribute :database_engine attribute :database_version attribute :size attribute :created_at, :type => :time attribute :updated_at, :type => :time attribute :deleted_at, :type => :time def save options = { :name => name, :description => description } data = update_database_snapshot(options) merge_attributes(data) true end def ready? state == "available" end def destroy requires :identity merge_attributes(service.destroy_database_snapshot(identity)) true end private def update_database_snapshot(options) service.update_database_snaphot(identity, options) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/load_balancers.rb0000644000004100000410000000101012464011624026026 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/load_balancer" module Fog module Compute class Brightbox class LoadBalancers < Fog::Collection model Fog::Compute::Brightbox::LoadBalancer def all data = service.list_load_balancers load(data) end def get(identifier) data = service.get_load_balancer(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/collaboration.rb0000644000004100000410000000216212464011624025736 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class Collaboration < Fog::Brightbox::Model identity :id attribute :status attribute :email attribute :role attribute :role_label attribute :account attribute :user attribute :inviter def account_id account["id"] || account[:id] end def save raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if identity options = { :role => role, :email => email }.delete_if { |_k, v| v.nil? || v == "" } data = service.create_collaboration(options) merge_attributes(data) true end def resend requires :identity data = service.resend_collaboration(identity) merge_attributes(data) true end def destroy requires :identity data = service.destroy_collaboration(identity) merge_attributes(data) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/user.rb0000644000004100000410000000151612464011624024066 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class User < Fog::Brightbox::Model identity :id attribute :resource_type attribute :url attribute :name attribute :email_address attribute :ssh_key # Boolean flags attribute :email_verified attribute :messaging_pref # Links - to be replaced attribute :account_id, :aliases => "default_account", :squash => "id" attribute :accounts def save requires :identity options = { :email_address => email_address, :ssh_key => ssh_key, :name => name } data = service.update_user(identity, options) merge_attributes(data) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/event.rb0000644000004100000410000000077512464011624024237 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox # @api private class Event < Fog::Brightbox::Model identity :id attribute :url attribute :resource_type attribute :action attribute :message attribute :short_message # Times attribute :created_at, :type => :time # Links - to be replaced attribute :resource attribute :client attribute :user end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/collaborations.rb0000644000004100000410000000251712464011624026125 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/collaboration" module Fog module Compute class Brightbox class Collaborations < Fog::Collection model Fog::Compute::Brightbox::Collaboration def all data = service.list_collaborations load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" data = service.get_collaboration(identifier) new(data) rescue Excon::Errors::NotFound nil end # Invites a user (via an email) to collaborate on the currently scoped # account at the +role+ level. # # @param [String] email The email address to use for the invitation # @param [String] role The role being granted. Only (+admin+ is # currently supported # @return [Fog::Compute::Brightbox::Collaboration] # def invite(email, role) return nil if email.nil? || email == "" return nil if role.nil? || role == "" options = { :email => email, :role => role } data = service.create_collaboration(options) new(data) end def destroy requires :identity service.destroy_collaboration(identity) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/server_groups.rb0000644000004100000410000000107712464011624026017 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/server_group" module Fog module Compute class Brightbox class ServerGroups < Fog::Collection model Fog::Compute::Brightbox::ServerGroup def all data = service.list_server_groups load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" data = service.get_server_group(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/flavors.rb0000644000004100000410000000076112464011624024565 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/flavor" module Fog module Compute class Brightbox class Flavors < Fog::Collection model Fog::Compute::Brightbox::Flavor def all data = service.list_server_types load(data) end def get(identifier) data = service.get_server_type(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/account.rb0000644000004100000410000000343512464011624024546 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class Account < Fog::Brightbox::Model identity :id attribute :url attribute :resource_type attribute :name attribute :status attribute :address_1 attribute :address_2 attribute :city attribute :county attribute :postcode attribute :country_code attribute :country_name attribute :vat_registration_number attribute :telephone_number attribute :verified_telephone attribute :verified_ip attribute :ram_limit attribute :ram_used attribute :cloud_ips_limit attribute :cloud_ips_used attribute :load_balancers_limit attribute :load_balancers_used attribute :library_ftp_host attribute :library_ftp_user # This is always returned as nil unless after a call to reset_ftp_password attribute :library_ftp_password # Boolean flags attribute :valid_credit_card attribute :telephone_verified # Times attribute :created_at, :type => :time attribute :verified_at, :type => :time # Links - to be replaced attribute :owner_id, :aliases => "owner", :squash => "id" attribute :clients attribute :images attribute :servers attribute :users attribute :zones # Resets the account's image library FTP password returning the new value # # @return [String] Newly issue FTP password # def reset_ftp_password requires :identity data = service.reset_ftp_password_account(identity) merge_attributes(data) library_ftp_password end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/api_clients.rb0000644000004100000410000000077712464011624025412 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/api_client" module Fog module Compute class Brightbox class ApiClients < Fog::Collection model Fog::Compute::Brightbox::ApiClient def all data = service.list_api_clients load(data) end def get(identifier = nil) data = service.get_api_client(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/firewall_rules.rb0000644000004100000410000000074512464011624026132 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/firewall_rule" module Fog module Compute class Brightbox class FirewallRules < Fog::Collection model Fog::Compute::Brightbox::FirewallRule def get(identifier) return nil if identifier.nil? || identifier == "" data = service.get_firewall_rule(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/database_snapshots.rb0000644000004100000410000000103412464011624026751 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/database_snapshot" module Fog module Compute class Brightbox class DatabaseSnapshots < Fog::Collection model Fog::Compute::Brightbox::DatabaseSnapshot def all data = service.list_database_snapshots load(data) end def get(identifier) data = service.get_database_snapshot(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/zone.rb0000644000004100000410000000046612464011624024066 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class Zone < Fog::Brightbox::Model identity :id attribute :url attribute :resource_type attribute :status attribute :handle attribute :description end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/user_collaboration.rb0000644000004100000410000000167112464011624027000 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class UserCollaboration < Fog::Brightbox::Model identity :id attribute :status attribute :email attribute :role attribute :role_label attribute :account attribute :user attribute :inviter def account_id account["id"] || account[:id] end def accept requires :identity data = service.accept_user_collaboration(identity) merge_attributes(data) true end def reject requires :identity data = service.reject_user_collaboration(identity) merge_attributes(data) true end def destroy requires :identity data = service.destroy_user_collaboration(identity) merge_attributes(data) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/firewall_policies.rb0000644000004100000410000000112012464011624026573 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/firewall_policy" module Fog module Compute class Brightbox class FirewallPolicies < Fog::Collection model Fog::Compute::Brightbox::FirewallPolicy def all data = service.list_firewall_policies load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" data = service.get_firewall_policy(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/server_group.rb0000644000004100000410000000542612464011624025636 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox # A server group is a collection of servers # # Certain actions can accept a server group and affect all members class ServerGroup < Fog::Brightbox::Model identity :id attribute :url attribute :resource_type attribute :name attribute :description attribute :default attribute :created_at, :type => :time attribute :server_ids, :aliases => "servers" def save options = { :name => name, :description => description }.delete_if { |_k, v| v.nil? || v == "" } data = service.create_server_group(options) merge_attributes(data) true end def servers srv_ids = server_ids.map { |srv| srv["id"] } srv_ids.map do |srv_id| service.servers.get(srv_id) end end # Adds specified servers to this server group # # @param [Array] identifiers array of server identifier strings to add # @return [Fog::Compute::ServerGroup] def add_servers(identifiers) requires :identity options = { :servers => server_references(identifiers) } data = service.add_servers_server_group identity, options merge_attributes data end # Removes specified servers from this server group # # @param [Array] identifiers array of server identifier strings to remove # @return [Fog::Compute::ServerGroup] def remove_servers(identifiers) requires :identity options = { :servers => server_references(identifiers) } data = service.remove_servers_server_group identity, options merge_attributes data end # Moves specified servers from this server group to the specified destination server group # # @param [Array] identifiers array of server identifier strings to move # @param [String] destination_group_id destination server group identifier # @return [Fog::Compute::ServerGroup] def move_servers(identifiers, destination_group_id) requires :identity options = { :servers => server_references(identifiers), :destination => destination_group_id } data = service.move_servers_server_group identity, options merge_attributes data end def destroy requires :identity service.destroy_server_group(identity) true end protected def server_references(identifiers) identifiers.map { |id| { "server" => id } } end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/firewall_rule.rb0000644000004100000410000000273312464011624025746 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class FirewallRule < Fog::Brightbox::Model identity :id attribute :url attribute :resource_type attribute :description attribute :source attribute :source_port attribute :destination attribute :destination_port attribute :protocol attribute :icmp_type_name attribute :created_at, :type => :time attribute :firewall_policy_id, :aliases => "firewall_policy", :squash => "id" # Sticking with existing Fog behaviour, save does not update but creates a new resource def save raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted? requires :firewall_policy_id options = { :firewall_policy => firewall_policy_id, :protocol => protocol, :description => description, :source => source, :source_port => source_port, :destination => destination, :destination_port => destination_port, :icmp_type_name => icmp_type_name }.delete_if { |_k, v| v.nil? || v == "" } data = service.create_firewall_rule(options) merge_attributes(data) true end def destroy requires :identity service.destroy_firewall_rule(identity) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/events.rb0000644000004100000410000000050112464011624024405 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/event" module Fog module Compute class Brightbox class Events < Fog::Collection model Fog::Compute::Brightbox::Event def all data = service.list_events load(data) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/applications.rb0000644000004100000410000000100012464011624025562 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/application" module Fog module Compute class Brightbox class Applications < Fog::Collection model Fog::Compute::Brightbox::Application def all data = service.list_applications load(data) end def get(identifier) data = service.get_application(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/users.rb0000644000004100000410000000074312464011624024252 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/user" module Fog module Compute class Brightbox class Users < Fog::Collection model Fog::Compute::Brightbox::User def all data = service.list_users load(data) end def get(identifier = nil) data = service.get_user(identifier) new(data) rescue Excon::Errors::NotFound nil end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/cloud_ips.rb0000644000004100000410000000121212464011624025062 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/cloud_ip" module Fog module Compute class Brightbox class CloudIps < Fog::Collection model Fog::Compute::Brightbox::CloudIp def all data = service.list_cloud_ips load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" data = service.get_cloud_ip(identifier) new(data) rescue Excon::Errors::NotFound nil end def allocate data = service.create_cloud_ip new(data) end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/flavor.rb0000644000004100000410000000111112464011624024370 0ustar www-datawww-datarequire "fog/brightbox/model" module Fog module Compute class Brightbox class Flavor < Fog::Brightbox::Model identity :id attribute :url attribute :resource_type attribute :name attribute :status attribute :description attribute :handle attribute :bits attribute :cores attribute :disk, :aliases => "disk_size" attribute :ram def bits 0 # This is actually based on the Image type used. 32bit or 64bit Images are supported end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/server.rb0000644000004100000410000001251112464011624024413 0ustar www-datawww-datarequire "fog/compute/models/server" require "fog/brightbox/compute/resource_locking" module Fog module Compute class Brightbox class Server < Fog::Compute::Server include Fog::Brightbox::ModelHelper include Fog::Brightbox::Compute::ResourceLocking identity :id attribute :resource_type attribute :url attribute :name attribute :state, :aliases => "status" attribute :hostname attribute :fqdn attribute :user_data attribute :console_url attribute :fqdn attribute :console_token # Times attribute :created_at, :type => :time attribute :started_at, :type => :time attribute :console_token_expires, :type => :time attribute :deleted_at, :type => :time # Links - to be replaced attribute :account_id, :aliases => "account", :squash => "id" attribute :image_id, :aliases => "image", :squash => "id" attribute :snapshots attribute :cloud_ips attribute :interfaces attribute :server_groups attribute :zone attribute :server_type def initialize(attributes = {}) # Call super first to initialize the service object for our default image super self.image_id ||= service.default_image end def zone_id if t_zone_id = attributes[:zone_id] t_zone_id elsif zone zone[:id] || zone["id"] end end def flavor_id if t_flavour_id = attributes[:flavor_id] t_flavour_id elsif server_type server_type[:id] || server_type["id"] end end def zone_id=(incoming_zone_id) attributes[:zone_id] = incoming_zone_id end def flavor_id=(incoming_flavour_id) attributes[:flavor_id] = incoming_flavour_id end def snapshot(return_snapshot = false) requires :identity response, snapshot_id = service.snapshot_server(identity, :return_link => return_snapshot) if return_snapshot service.images.get(snapshot_id) else response end end # Issues a hard reset to the server (or an OS level reboot command) # # Default behaviour is a hard reboot because it is more reliable # because the state of the server's OS is irrelevant. # # @example Hard reset # @server.reboot # # @example Soft reset # @server.reboot(false) # # @param [Boolean] use_hard_reboot # @return [Boolean] def reboot(use_hard_reboot = true) requires :identity if ready? if use_hard_reboot service.reset_server(identity) else service.reboot_server(identity) end else # Not able to reboot if not ready in the first place false end end def start requires :identity service.start_server(identity) true end def stop requires :identity service.stop_server(identity) true end def shutdown requires :identity service.shutdown_server(identity) true end def destroy requires :identity service.destroy_server(identity) true end def flavor requires :flavor_id service.flavors.get(flavor_id) end def image requires :image_id service.images.get(image_id) end # Returns the public DNS name of the server # # @return [String] # def dns_name ["public", fqdn].join(".") end def private_ip_address if interfaces.empty? nil else interfaces.first["ipv4_address"] end end def public_ip_address if cloud_ips.empty? nil else cloud_ips.first["public_ip"] end end def ready? state == "active" end def activate_console requires :identity response = service.activate_console_server(identity) [response["console_url"], response["console_token"], response["console_token_expires"]] end def save raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted? requires :image_id options = { :image => image_id, :name => name, :zone => zone_id, :user_data => user_data, :server_groups => server_groups }.delete_if { |_k, v| v.nil? || v == "" } options.merge!(:server_type => flavor_id) unless flavor_id.nil? || flavor_id == "" data = service.create_server(options) merge_attributes(data) true end # Replaces the server's identifier with it's interface's identifier for Cloud IP mapping # # @return [String] the identifier to pass to a Cloud IP mapping request def mapping_identity interfaces.first["id"] end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/image.rb0000644000004100000410000000316512464011624024174 0ustar www-datawww-datarequire "fog/brightbox/model" require "fog/brightbox/compute/resource_locking" module Fog module Compute class Brightbox class Image < Fog::Brightbox::Model include Fog::Brightbox::Compute::ResourceLocking identity :id attribute :url attribute :resource_type attribute :name attribute :username attribute :status attribute :description attribute :source attribute :source_type attribute :arch attribute :virtual_size attribute :disk_size attribute :licence_name # Boolean flags attribute :public attribute :official attribute :compatibility_mode # Times attribute :created_at, :type => :time # Links - to be replaced attribute :ancestor_id, :aliases => "ancestor", :squash => "id" attribute :owner_id, :aliases => "owner", :squash => "id" def ready? status == "available" end def save raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted? requires :source, :arch options = { :source => source, :arch => arch, :name => name, :username => username, :description => description }.delete_if { |_k, v| v.nil? || v == "" } data = service.create_image(options) merge_attributes(data) true end def destroy requires :identity service.destroy_image(identity) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/models/compute/user_collaborations.rb0000644000004100000410000000134112464011624027155 0ustar www-datawww-datarequire "fog/core/collection" require "fog/brightbox/models/compute/user_collaboration" module Fog module Compute class Brightbox class UserCollaborations < Fog::Collection model Fog::Compute::Brightbox::UserCollaboration def all data = service.list_user_collaborations load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" data = service.get_user_collaboration(identifier) new(data) rescue Excon::Errors::NotFound nil end def destroy requires :identity service.destroy_user_collaboration(identity) true end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/model_helper.rb0000644000004100000410000000041112464011624022601 0ustar www-datawww-datarequire "inflecto" module Fog module Brightbox module ModelHelper def resource_name Inflecto.underscore(Inflecto.demodulize(self.class)) end def collection_name Inflecto.pluralize(resource_name) end end end end fog-brightbox-0.7.1/lib/fog/brightbox/oauth2.rb0000644000004100000410000001305012464011624021347 0ustar www-datawww-data# This module covers Brightbox's partial implementation of OAuth 2.0 # and enables fog clients to implement several authentictication strategies # # @see http://tools.ietf.org/html/draft-ietf-oauth-v2-10 # module Fog module Brightbox module OAuth2 # This builds the simplest form of requesting an access token # based on the arguments passed in # # @param [Fog::Core::Connection] connection # @param [CredentialSet] credentials # # @return [Excon::Response] def request_access_token(connection, credentials) token_strategy = credentials.best_grant_strategy header_content = "#{credentials.client_id}:#{credentials.client_secret}" encoded_credentials = Base64.encode64(header_content).chomp connection.request( :path => "/token", :expects => 200, :headers => { "Authorization" => "Basic #{encoded_credentials}", "Content-Type" => "application/json" }, :method => "POST", :body => Fog::JSON.encode(token_strategy.authorization_body_data) ) end # Encapsulates credentials required to request access tokens from the # Brightbox authorisation servers # # @todo Interface to update certain credentials (after password change) # class CredentialSet attr_reader :client_id, :client_secret, :username, :password attr_reader :access_token, :refresh_token, :expires_in # # @param [String] client_id # @param [String] client_secret # @param [Hash] options # @option options [String] :username # @option options [String] :password # def initialize(client_id, client_secret, options = {}) @client_id = client_id @client_secret = client_secret @username = options[:username] @password = options[:password] @access_token = options[:access_token] @refresh_token = options[:refresh_token] @expires_in = options[:expires_in] end # Returns true if user details are available # @return [Boolean] def user_details? !!(@username && @password) end # Is an access token available for these credentials? def access_token? !!@access_token end # Is a refresh token available for these credentials? def refresh_token? !!@refresh_token end # Updates the credentials with newer tokens def update_tokens(access_token, refresh_token = nil, expires_in = nil) @access_token = access_token @refresh_token = refresh_token @expires_in = expires_in end # Based on available credentials returns the best strategy # # @todo Add a means to dictate which should or shouldn't be used # def best_grant_strategy if refresh_token? RefreshTokenStrategy.new(self) elsif user_details? UserCredentialsStrategy.new(self) else ClientCredentialsStrategy.new(self) end end end # This strategy class is the basis for OAuth2 grant types # # @abstract Need to implement {#authorization_body_data} to return a # Hash matching the expected parameter form for the OAuth request # # @todo Strategies should be able to validate if credentials are suitable # so just client credentials cannot be used with user strategies # class GrantTypeStrategy def initialize(credentials) @credentials = credentials end def authorization_body_data raise "Not implemented" end end # This implements client based authentication/authorization # based on the existing trust relationship using the `none` # grant type. # class ClientCredentialsStrategy < GrantTypeStrategy def authorization_body_data { "grant_type" => "none", "client_id" => @credentials.client_id } end end # This passes user details through so the returned token # carries the privileges of the user not account limited # by the client # class UserCredentialsStrategy < GrantTypeStrategy def authorization_body_data { "grant_type" => "password", "client_id" => @credentials.client_id, "username" => @credentials.username, "password" => @credentials.password } end end # This strategy attempts to use a refresh_token gained during an earlier # request to reuse the credentials given originally # class RefreshTokenStrategy < GrantTypeStrategy def authorization_body_data { "grant_type" => "refresh_token", "client_id" => @credentials.client_id, "refresh_token" => @credentials.refresh_token } end end private # This updates the current credentials if passed a valid response # # @param [CredentialSet] credentials Credentials to update # @param [Excon::Response] response Response object to parse value from # def update_credentials_from_response(credentials, response) response_data = Fog::JSON.decode(response.body) credentials.update_tokens(response_data["access_token"], response_data["refresh_token"], response_data["expires_in"]) end end end end fog-brightbox-0.7.1/lib/fog/brightbox/compute.rb0000644000004100000410000002666512464011624021641 0ustar www-datawww-datarequire "fog/brightbox/core" require "fog/brightbox/compute/config" require "fog/brightbox/compute/shared" require "fog/brightbox/compute/image_selector" require "fog/brightbox/link_helper" module Fog module Compute class Brightbox < Fog::Service # Client credentials requires :brightbox_client_id, :brightbox_secret # API endpoint settings recognizes :brightbox_auth_url, :brightbox_api_url # User credentials (still requires client details) recognizes :brightbox_username, :brightbox_password, :brightbox_account # Cached tokens recognizes :brightbox_access_token, :brightbox_refresh_token # Automatic token management recognizes :brightbox_token_management # Excon connection settings recognizes :persistent model_path "fog/brightbox/models/compute" collection :accounts model :account collection :applications model :application collection :api_clients model :api_client collection :collaborations model :collaboration collection :servers model :server collection :server_groups model :server_group collection :events model :event collection :firewall_policies model :firewall_policy collection :firewall_rules model :firewall_rule collection :flavors model :flavor collection :images model :image collection :load_balancers model :load_balancer collection :database_servers model :database_server collection :database_snapshots model :database_snapshot collection :database_types model :database_type collection :zones model :zone collection :cloud_ips model :cloud_ip collection :users model :user collection :user_collaborations model :user_collaboration request_path "fog/brightbox/requests/compute" request :accept_user_collaboration request :activate_console_server request :add_listeners_load_balancer request :add_nodes_load_balancer request :add_servers_server_group request :apply_to_firewall_policy request :accept_user_collaboration request :remove_firewall_policy request :create_api_client request :create_application request :create_cloud_ip request :create_collaboration request :create_firewall_policy request :create_firewall_rule request :create_image request :create_load_balancer request :create_database_server request :create_server request :create_server_group request :delete_api_client request :delete_application request :delete_cloud_ip request :delete_collaboration request :delete_firewall_policy request :delete_firewall_rule request :delete_image request :delete_load_balancer request :delete_database_server request :delete_database_snapshot request :delete_server request :delete_server_group request :delete_user_collaboration request :get_account request :get_api_client request :get_application request :get_authenticated_user request :get_cloud_ip request :get_collaboration request :get_firewall_policy request :get_firewall_rule request :get_image request :get_interface request :get_load_balancer request :get_database_server request :get_database_snapshot request :get_database_type request :get_scoped_account request :get_server request :get_server_group request :get_server_type request :get_user request :get_user_collaboration request :get_zone request :list_accounts request :list_api_clients request :list_applications request :list_cloud_ips request :list_collaborations request :list_events request :list_firewall_policies request :list_images request :list_load_balancers request :list_database_servers request :list_database_snapshots request :list_database_types request :list_server_groups request :list_server_types request :list_servers request :list_users request :list_user_collaborations request :list_zones request :lock_resource_database_server request :lock_resource_database_snapshot request :lock_resource_image request :lock_resource_load_balancer request :lock_resource_server request :map_cloud_ip request :move_servers_server_group request :reboot_server request :reject_user_collaboration request :remove_listeners_load_balancer request :remove_nodes_load_balancer request :remove_servers_server_group request :resend_collaboration request :reset_ftp_password_account request :reset_ftp_password_scoped_account request :reset_password_database_server request :reset_secret_api_client request :reset_secret_application request :reset_server request :resend_collaboration request :reject_user_collaboration request :shutdown_server request :snapshot_database_server request :snapshot_server request :start_server request :stop_server request :unlock_resource_database_server request :unlock_resource_database_snapshot request :unlock_resource_image request :unlock_resource_load_balancer request :unlock_resource_server request :unmap_cloud_ip request :update_account request :update_api_client request :update_application request :update_cloud_ip request :update_firewall_policy request :update_firewall_rule request :update_image request :update_load_balancer request :update_database_server request :update_database_snapshot request :update_scoped_account request :update_server request :update_server_group request :update_user # The Mock Service allows you to run a fake instance of the Service # which makes no real connections. # # @todo Implement # class Mock include Fog::Brightbox::Compute::Shared def request(_method, _path, _expected_responses, _parameters = {}) _request end def request_access_token(_connection, _credentials) _request end private def _request raise Fog::Errors::MockNotImplemented end def select_default_image "img-mockd" end end # The Real Service actually makes real connections to the Brightbox # service. # class Real include Fog::Brightbox::Compute::Shared # Makes an API request to the given path using passed options or those # set with the service setup # # @todo Standard Fog behaviour is to return the Excon::Response but # this was unintentionally changed to be the Hash version of the # data in the body. This loses access to some details and should # be corrected in a backwards compatible manner # # @overload request(params) # @param [Hash] params Excon compatible options # @option params [String] :body text to be sent over a socket # @option params [Hash] :headers The default headers to supply in a request # @option params [String] :host The destination host's reachable DNS name or IP, in the form of a String # @option params [String] :path appears after 'scheme://host:port/' # @option params [Fixnum] :port The port on which to connect, to the destination host # @option params [Hash] :query appended to the 'scheme://host:port/path/' in the form of '?key=value' # @option params [String] :scheme The protocol; 'https' causes OpenSSL to be used # @return [Excon::Response] # @see https://github.com/geemus/excon/blob/master/lib/excon/connection.rb # # @overload request(method, path, expected_responses, params = {}) # @param [String] method HTTP method to use for the request # @param [String] path The absolute path for the request # @param [Array] expected_responses HTTP response codes that have been successful # @param [Hash] params Keys and values for JSON # @option params [String] :account_id The scoping account if required # @deprecated #request with multiple arguments is deprecated # since it is inconsistent with original fog version. # @return [Hash] def request(*args) if args.size == 1 authenticated_request(*args) else Fog::Logger.deprecation("#request with multiple parameters is deprecated, use #wrapped_request instead [light_black](#{caller.first})[/]") wrapped_request(*args) end end # Makes a request but with seperated arguments and parses the response to a hash # # @note #wrapped_request is the non-standard form of request introduced by mistake # # @param [String] method HTTP method to use for the request # @param [String] path The absolute path for the request # @param [Array] expected_responses HTTP response codes that have been successful # @param [Hash] parameters Keys and values for JSON # @option parameters [String] :account_id The scoping account if required # # @return [Hash] def wrapped_request(method, path, expected_responses, parameters = {}) _wrapped_request(method, path, expected_responses, parameters) end private # Wrapped request is the non-standard form of request introduced by mistake # # @param [String] method HTTP method to use for the request # @param [String] path The absolute path for the request # @param [Array] expected_responses HTTP response codes that have been successful # @param [Hash] parameters Keys and values for JSON # @option parameters [String] :account_id The scoping account if required # # @return [Hash] def _wrapped_request(method, path, expected_responses, parameters = {}) request_options = { :method => method.to_s.upcase, :path => path, :expects => expected_responses } # Select the account to scope for this request account = scoped_account(parameters.fetch(:account_id, nil)) request_options[:query] = { :account_id => account } if account request_options[:body] = Fog::JSON.encode(parameters) unless parameters.empty? response = make_request(request_options) # FIXME: We should revert to returning the Excon::Request after a suitable # configuration option is in place to switch back to this incorrect behaviour if response.body.empty? response else Fog::JSON.decode(response.body) end end # Queries the API and tries to select the most suitable official Image # to use if the user chooses not to select their own. # # @return [String] if image is found, the image's identifier # @return [NilClass] if no image found or an error occured # def select_default_image Fog::Brightbox::Compute::ImageSelector.new(list_images).latest_ubuntu end end end end end fog-brightbox-0.7.1/lib/fog/brightbox/storage.rb0000644000004100000410000001126612464011624021620 0ustar www-datawww-datarequire "fog/brightbox/core" require "fog/brightbox/storage/errors" require "fog/brightbox/storage/config" require "fog/brightbox/storage/authentication_request" require "fog/brightbox/storage/connection" module Fog module Storage class Brightbox < Fog::Service requires :brightbox_client_id, :brightbox_secret recognizes :persistent, :brightbox_service_name, :brightbox_storage_url, :brightbox_service_type, :brightbox_tenant, :brightbox_region, :brightbox_temp_url_key model_path "fog/brightbox/models/storage" model :directory collection :directories model :file collection :files request_path "fog/brightbox/requests/storage" request :copy_object request :delete_container request :delete_object request :delete_multiple_objects request :delete_static_large_object request :get_container request :get_containers request :get_object request :get_object_http_url request :get_object_https_url request :head_container request :head_containers request :head_object request :post_set_meta_temp_url_key request :put_container request :put_dynamic_obj_manifest request :put_object request :put_object_manifest request :put_static_obj_manifest class Mock def initialize(_options = {}) end end class Real def initialize(config) if config.respond_to?(:config_service?) && config.config_service? @config = config else @config = Fog::Brightbox::Config.new(config) end @config = Fog::Brightbox::Storage::Config.new(@config) @temp_url_key = @config.storage_temp_key end def needs_to_authenticate? @config.must_authenticate? end def authentication_url @auth_url ||= URI.parse(@config.storage_url.to_s) end def management_url @config.storage_management_url end def reload @connection.reset end def account @config.account end def change_account(account) @config.change_account(account) end def reset_account_name @config.reset_account end def connection @connection ||= Fog::Brightbox::Storage::Connection.new(@config) end def request(params, parse_json = true) authenticate if @config.must_authenticate? connection.request(params, parse_json) rescue Fog::Brightbox::Storage::AuthenticationRequired => error if @config.managed_tokens? @config.expire_tokens! authenticate retry else # bad credentials raise error end rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Storage::Brightbox::NotFound.slurp(error) else error end end def authenticate if !management_url || needs_to_authenticate? response = Fog::Brightbox::Storage::AuthenticationRequest.new(@config).authenticate if response.nil? return false else update_config_from_auth_response(response) end else false end end # @param [URI] url A URI object to extract the account from # @return [String] The account def extract_account_from_url(url) url.path.split("/")[2] end private def update_config_from_auth_response(response) @config.update_tokens(response.access_token) # Only update the management URL if not set return true if management_url && account unless management_url new_management_url = response.management_url if new_management_url && new_management_url != management_url.to_s @config.storage_management_url = URI.parse(new_management_url) end end unless account # Extract the account ID sent by the server change_account(extract_account_from_url(@config.storage_management_url)) end true end end # CGI.escape, but without special treatment on spaces def self.escape(str, extra_exclude_chars = "") str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do "%" + Regexp.last_match[1].unpack("H2" * Regexp.last_match[1].bytesize).join("%").upcase end end end end end fog-brightbox-0.7.1/gemfiles/0000755000004100000410000000000012464011624016103 5ustar www-datawww-datafog-brightbox-0.7.1/gemfiles/Gemfile.1.8.70000644000004100000410000000022712464011624020051 0ustar www-datawww-datasource "https://rubygems.org" gem "fog-core", :github => "fog/fog-core" gem "mime-types", "~> 1.22" gem "inflecto", "~> 0.0.2" gemspec :path => ".." fog-brightbox-0.7.1/.rubocop.yml0000644000004100000410000000064412464011624016566 0ustar www-datawww-datainherit_from: .rubocop_todo.yml HashSyntax: EnforcedStyle: hash_rockets LineLength: Max: 100 Enabled: false StringLiterals: EnforcedStyle: double_quotes Encoding: Description: 'Use UTF-8 as the source file encoding.' Enabled: false SignalException: Description: 'Do not enforce use of fail when raising exceptions.' # Valid values are: semantic, only_raise and only_fail EnforcedStyle: only_raise fog-brightbox-0.7.1/metadata.yml0000644000004100000410000004266112464011624016624 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: fog-brightbox version: !ruby/object:Gem::Version version: 0.7.1 platform: ruby authors: - Paul Thornthwaite autorequire: bindir: bin cert_chain: [] date: 2014-12-05 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: fog-core requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.22' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.22' - !ruby/object:Gem::Dependency name: fog-json requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: inflecto requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: 0.0.2 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: 0.0.2 - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.3' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.3' - !ruby/object:Gem::Dependency name: minitest requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: pry requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: webmock requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: yard requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' description: Module for the 'fog' gem to support Brightbox Cloud email: - tokengeek@gmail.com executables: [] extensions: [] extra_rdoc_files: [] files: - ".gitignore" - ".rubocop.yml" - ".rubocop_todo.yml" - ".travis.yml" - CHANGELOG.md - Gemfile - LICENSE.txt - README.md - Rakefile - fog-brightbox.gemspec - gemfiles/Gemfile.1.8.7 - lib/fog/brightbox.rb - lib/fog/brightbox/compute.rb - lib/fog/brightbox/compute/config.rb - lib/fog/brightbox/compute/image_selector.rb - lib/fog/brightbox/compute/resource_locking.rb - lib/fog/brightbox/compute/shared.rb - lib/fog/brightbox/config.rb - lib/fog/brightbox/core.rb - lib/fog/brightbox/link_helper.rb - lib/fog/brightbox/model.rb - lib/fog/brightbox/model_helper.rb - lib/fog/brightbox/models/compute/account.rb - lib/fog/brightbox/models/compute/accounts.rb - lib/fog/brightbox/models/compute/api_client.rb - lib/fog/brightbox/models/compute/api_clients.rb - lib/fog/brightbox/models/compute/application.rb - lib/fog/brightbox/models/compute/applications.rb - lib/fog/brightbox/models/compute/cloud_ip.rb - lib/fog/brightbox/models/compute/cloud_ips.rb - lib/fog/brightbox/models/compute/collaboration.rb - lib/fog/brightbox/models/compute/collaborations.rb - lib/fog/brightbox/models/compute/database_server.rb - lib/fog/brightbox/models/compute/database_servers.rb - lib/fog/brightbox/models/compute/database_snapshot.rb - lib/fog/brightbox/models/compute/database_snapshots.rb - lib/fog/brightbox/models/compute/database_type.rb - lib/fog/brightbox/models/compute/database_types.rb - lib/fog/brightbox/models/compute/event.rb - lib/fog/brightbox/models/compute/events.rb - lib/fog/brightbox/models/compute/firewall_policies.rb - lib/fog/brightbox/models/compute/firewall_policy.rb - lib/fog/brightbox/models/compute/firewall_rule.rb - lib/fog/brightbox/models/compute/firewall_rules.rb - lib/fog/brightbox/models/compute/flavor.rb - lib/fog/brightbox/models/compute/flavors.rb - lib/fog/brightbox/models/compute/image.rb - lib/fog/brightbox/models/compute/images.rb - lib/fog/brightbox/models/compute/load_balancer.rb - lib/fog/brightbox/models/compute/load_balancers.rb - lib/fog/brightbox/models/compute/server.rb - lib/fog/brightbox/models/compute/server_group.rb - lib/fog/brightbox/models/compute/server_groups.rb - lib/fog/brightbox/models/compute/servers.rb - lib/fog/brightbox/models/compute/user.rb - lib/fog/brightbox/models/compute/user_collaboration.rb - lib/fog/brightbox/models/compute/user_collaborations.rb - lib/fog/brightbox/models/compute/users.rb - lib/fog/brightbox/models/compute/zone.rb - lib/fog/brightbox/models/compute/zones.rb - lib/fog/brightbox/models/storage/directories.rb - lib/fog/brightbox/models/storage/directory.rb - lib/fog/brightbox/models/storage/file.rb - lib/fog/brightbox/models/storage/files.rb - lib/fog/brightbox/oauth2.rb - lib/fog/brightbox/requests/compute/accept_user_collaboration.rb - lib/fog/brightbox/requests/compute/activate_console_server.rb - lib/fog/brightbox/requests/compute/add_listeners_load_balancer.rb - lib/fog/brightbox/requests/compute/add_nodes_load_balancer.rb - lib/fog/brightbox/requests/compute/add_servers_server_group.rb - lib/fog/brightbox/requests/compute/apply_to_firewall_policy.rb - lib/fog/brightbox/requests/compute/create_api_client.rb - lib/fog/brightbox/requests/compute/create_application.rb - lib/fog/brightbox/requests/compute/create_cloud_ip.rb - lib/fog/brightbox/requests/compute/create_collaboration.rb - lib/fog/brightbox/requests/compute/create_database_server.rb - lib/fog/brightbox/requests/compute/create_firewall_policy.rb - lib/fog/brightbox/requests/compute/create_firewall_rule.rb - lib/fog/brightbox/requests/compute/create_image.rb - lib/fog/brightbox/requests/compute/create_load_balancer.rb - lib/fog/brightbox/requests/compute/create_server.rb - lib/fog/brightbox/requests/compute/create_server_group.rb - lib/fog/brightbox/requests/compute/delete_api_client.rb - lib/fog/brightbox/requests/compute/delete_application.rb - lib/fog/brightbox/requests/compute/delete_cloud_ip.rb - lib/fog/brightbox/requests/compute/delete_collaboration.rb - lib/fog/brightbox/requests/compute/delete_database_server.rb - lib/fog/brightbox/requests/compute/delete_database_snapshot.rb - lib/fog/brightbox/requests/compute/delete_firewall_policy.rb - lib/fog/brightbox/requests/compute/delete_firewall_rule.rb - lib/fog/brightbox/requests/compute/delete_image.rb - lib/fog/brightbox/requests/compute/delete_load_balancer.rb - lib/fog/brightbox/requests/compute/delete_server.rb - lib/fog/brightbox/requests/compute/delete_server_group.rb - lib/fog/brightbox/requests/compute/delete_user_collaboration.rb - lib/fog/brightbox/requests/compute/get_account.rb - lib/fog/brightbox/requests/compute/get_api_client.rb - lib/fog/brightbox/requests/compute/get_application.rb - lib/fog/brightbox/requests/compute/get_authenticated_user.rb - lib/fog/brightbox/requests/compute/get_cloud_ip.rb - lib/fog/brightbox/requests/compute/get_collaboration.rb - lib/fog/brightbox/requests/compute/get_database_server.rb - lib/fog/brightbox/requests/compute/get_database_snapshot.rb - lib/fog/brightbox/requests/compute/get_database_type.rb - lib/fog/brightbox/requests/compute/get_firewall_policy.rb - lib/fog/brightbox/requests/compute/get_firewall_rule.rb - lib/fog/brightbox/requests/compute/get_image.rb - lib/fog/brightbox/requests/compute/get_interface.rb - lib/fog/brightbox/requests/compute/get_load_balancer.rb - lib/fog/brightbox/requests/compute/get_scoped_account.rb - lib/fog/brightbox/requests/compute/get_server.rb - lib/fog/brightbox/requests/compute/get_server_group.rb - lib/fog/brightbox/requests/compute/get_server_type.rb - lib/fog/brightbox/requests/compute/get_user.rb - lib/fog/brightbox/requests/compute/get_user_collaboration.rb - lib/fog/brightbox/requests/compute/get_zone.rb - lib/fog/brightbox/requests/compute/list_accounts.rb - lib/fog/brightbox/requests/compute/list_api_clients.rb - lib/fog/brightbox/requests/compute/list_applications.rb - lib/fog/brightbox/requests/compute/list_cloud_ips.rb - lib/fog/brightbox/requests/compute/list_collaborations.rb - lib/fog/brightbox/requests/compute/list_database_servers.rb - lib/fog/brightbox/requests/compute/list_database_snapshots.rb - lib/fog/brightbox/requests/compute/list_database_types.rb - lib/fog/brightbox/requests/compute/list_events.rb - lib/fog/brightbox/requests/compute/list_firewall_policies.rb - lib/fog/brightbox/requests/compute/list_images.rb - lib/fog/brightbox/requests/compute/list_load_balancers.rb - lib/fog/brightbox/requests/compute/list_server_groups.rb - lib/fog/brightbox/requests/compute/list_server_types.rb - lib/fog/brightbox/requests/compute/list_servers.rb - lib/fog/brightbox/requests/compute/list_user_collaborations.rb - lib/fog/brightbox/requests/compute/list_users.rb - lib/fog/brightbox/requests/compute/list_zones.rb - lib/fog/brightbox/requests/compute/lock_resource_database_server.rb - lib/fog/brightbox/requests/compute/lock_resource_database_snapshot.rb - lib/fog/brightbox/requests/compute/lock_resource_image.rb - lib/fog/brightbox/requests/compute/lock_resource_load_balancer.rb - lib/fog/brightbox/requests/compute/lock_resource_server.rb - lib/fog/brightbox/requests/compute/map_cloud_ip.rb - lib/fog/brightbox/requests/compute/move_servers_server_group.rb - lib/fog/brightbox/requests/compute/reboot_server.rb - lib/fog/brightbox/requests/compute/reject_user_collaboration.rb - lib/fog/brightbox/requests/compute/remove_firewall_policy.rb - lib/fog/brightbox/requests/compute/remove_listeners_load_balancer.rb - lib/fog/brightbox/requests/compute/remove_nodes_load_balancer.rb - lib/fog/brightbox/requests/compute/remove_servers_server_group.rb - lib/fog/brightbox/requests/compute/resend_collaboration.rb - lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb - lib/fog/brightbox/requests/compute/reset_ftp_password_scoped_account.rb - lib/fog/brightbox/requests/compute/reset_password_database_server.rb - lib/fog/brightbox/requests/compute/reset_secret_api_client.rb - lib/fog/brightbox/requests/compute/reset_secret_application.rb - lib/fog/brightbox/requests/compute/reset_server.rb - lib/fog/brightbox/requests/compute/shutdown_server.rb - lib/fog/brightbox/requests/compute/snapshot_database_server.rb - lib/fog/brightbox/requests/compute/snapshot_server.rb - lib/fog/brightbox/requests/compute/start_server.rb - lib/fog/brightbox/requests/compute/stop_server.rb - lib/fog/brightbox/requests/compute/unlock_resource_database_server.rb - lib/fog/brightbox/requests/compute/unlock_resource_database_snapshot.rb - lib/fog/brightbox/requests/compute/unlock_resource_image.rb - lib/fog/brightbox/requests/compute/unlock_resource_load_balancer.rb - lib/fog/brightbox/requests/compute/unlock_resource_server.rb - lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb - lib/fog/brightbox/requests/compute/update_account.rb - lib/fog/brightbox/requests/compute/update_api_client.rb - lib/fog/brightbox/requests/compute/update_application.rb - lib/fog/brightbox/requests/compute/update_cloud_ip.rb - lib/fog/brightbox/requests/compute/update_database_server.rb - lib/fog/brightbox/requests/compute/update_database_snapshot.rb - lib/fog/brightbox/requests/compute/update_firewall_policy.rb - lib/fog/brightbox/requests/compute/update_firewall_rule.rb - lib/fog/brightbox/requests/compute/update_image.rb - lib/fog/brightbox/requests/compute/update_load_balancer.rb - lib/fog/brightbox/requests/compute/update_scoped_account.rb - lib/fog/brightbox/requests/compute/update_server.rb - lib/fog/brightbox/requests/compute/update_server_group.rb - lib/fog/brightbox/requests/compute/update_user.rb - lib/fog/brightbox/requests/storage/copy_object.rb - lib/fog/brightbox/requests/storage/delete_container.rb - lib/fog/brightbox/requests/storage/delete_multiple_objects.rb - lib/fog/brightbox/requests/storage/delete_object.rb - lib/fog/brightbox/requests/storage/delete_static_large_object.rb - lib/fog/brightbox/requests/storage/get_container.rb - lib/fog/brightbox/requests/storage/get_containers.rb - lib/fog/brightbox/requests/storage/get_object.rb - lib/fog/brightbox/requests/storage/get_object_http_url.rb - lib/fog/brightbox/requests/storage/get_object_https_url.rb - lib/fog/brightbox/requests/storage/head_container.rb - lib/fog/brightbox/requests/storage/head_containers.rb - lib/fog/brightbox/requests/storage/head_object.rb - lib/fog/brightbox/requests/storage/post_set_meta_temp_url_key.rb - lib/fog/brightbox/requests/storage/put_container.rb - lib/fog/brightbox/requests/storage/put_dynamic_obj_manifest.rb - lib/fog/brightbox/requests/storage/put_object.rb - lib/fog/brightbox/requests/storage/put_object_manifest.rb - lib/fog/brightbox/requests/storage/put_static_obj_manifest.rb - lib/fog/brightbox/storage.rb - lib/fog/brightbox/storage/authentication_request.rb - lib/fog/brightbox/storage/config.rb - lib/fog/brightbox/storage/connection.rb - lib/fog/brightbox/storage/errors.rb - lib/fog/brightbox/version.rb - spec/fog/brightbox/compute/config_spec.rb - spec/fog/brightbox/config_spec.rb - spec/fog/brightbox/link_helper_spec.rb - spec/fog/brightbox/storage/authentication_request_spec.rb - spec/fog/brightbox/storage/config_spec.rb - spec/fog/brightbox/storage/connection_errors_spec.rb - spec/fog/brightbox/storage/connection_spec.rb - spec/fog/compute/brightbox/account_spec.rb - spec/fog/compute/brightbox/api_client_spec.rb - spec/fog/compute/brightbox/application_spec.rb - spec/fog/compute/brightbox/cloud_ip_spec.rb - spec/fog/compute/brightbox/collaboration_spec.rb - spec/fog/compute/brightbox/database_server_spec.rb - spec/fog/compute/brightbox/database_snapshot_spec.rb - spec/fog/compute/brightbox/database_type_spec.rb - spec/fog/compute/brightbox/event_spec.rb - spec/fog/compute/brightbox/firewall_policy_spec.rb - spec/fog/compute/brightbox/flavor_spec.rb - spec/fog/compute/brightbox/image_spec.rb - spec/fog/compute/brightbox/load_balancer_spec.rb - spec/fog/compute/brightbox/server_group_spec.rb - spec/fog/compute/brightbox/server_spec.rb - spec/fog/compute/brightbox/user_collaboration_spec.rb - spec/fog/compute/brightbox/user_spec.rb - spec/fog/compute/brightbox/zone_spec.rb - spec/fog/compute/brightbox_spec.rb - spec/fog/storage/brightbox_spec.rb - spec/model_setup.rb - spec/spec_helper.rb - spec/stock_storage_responses.rb - spec/supports_resource_locking.rb homepage: '' licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: This library can be used as a module for `fog` or as standalone provider to use the Brightbox Cloud in applications test_files: - spec/fog/brightbox/compute/config_spec.rb - spec/fog/brightbox/config_spec.rb - spec/fog/brightbox/link_helper_spec.rb - spec/fog/brightbox/storage/authentication_request_spec.rb - spec/fog/brightbox/storage/config_spec.rb - spec/fog/brightbox/storage/connection_errors_spec.rb - spec/fog/brightbox/storage/connection_spec.rb - spec/fog/compute/brightbox/account_spec.rb - spec/fog/compute/brightbox/api_client_spec.rb - spec/fog/compute/brightbox/application_spec.rb - spec/fog/compute/brightbox/cloud_ip_spec.rb - spec/fog/compute/brightbox/collaboration_spec.rb - spec/fog/compute/brightbox/database_server_spec.rb - spec/fog/compute/brightbox/database_snapshot_spec.rb - spec/fog/compute/brightbox/database_type_spec.rb - spec/fog/compute/brightbox/event_spec.rb - spec/fog/compute/brightbox/firewall_policy_spec.rb - spec/fog/compute/brightbox/flavor_spec.rb - spec/fog/compute/brightbox/image_spec.rb - spec/fog/compute/brightbox/load_balancer_spec.rb - spec/fog/compute/brightbox/server_group_spec.rb - spec/fog/compute/brightbox/server_spec.rb - spec/fog/compute/brightbox/user_collaboration_spec.rb - spec/fog/compute/brightbox/user_spec.rb - spec/fog/compute/brightbox/zone_spec.rb - spec/fog/compute/brightbox_spec.rb - spec/fog/storage/brightbox_spec.rb - spec/model_setup.rb - spec/spec_helper.rb - spec/stock_storage_responses.rb - spec/supports_resource_locking.rb has_rdoc: fog-brightbox-0.7.1/.gitignore0000644000004100000410000000005712464011624016302 0ustar www-datawww-dataGemfile.lock gemfiles/*.lock pkg doc/* .yardoc fog-brightbox-0.7.1/fog-brightbox.gemspec0000644000004100000410000000242012464011624020414 0ustar www-datawww-data# coding: utf-8 lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "fog/brightbox/version" Gem::Specification.new do |spec| spec.name = "fog-brightbox" spec.version = Fog::Brightbox::VERSION spec.authors = ["Paul Thornthwaite"] spec.email = ["tokengeek@gmail.com"] spec.description = %q(Module for the 'fog' gem to support Brightbox Cloud) spec.summary = %q(This library can be used as a module for `fog` or as standalone provider to use the Brightbox Cloud in applications) spec.homepage = "" spec.license = "MIT" spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_dependency "fog-core", "~> 1.22" spec.add_dependency "fog-json" spec.add_dependency "inflecto", "~> 0.0.2" spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "minitest" spec.add_development_dependency "pry" spec.add_development_dependency "rake" spec.add_development_dependency "webmock" spec.add_development_dependency "yard" end fog-brightbox-0.7.1/CHANGELOG.md0000644000004100000410000000661112464011624016125 0ustar www-datawww-data### 0.7.1 / 2014-12-05 Bug fixes: * Fixed implementation of `Storage#create_temp_url` (except on Ruby 1.8.7) ### 0.7.0 / 2014-11-27 Enhancements: * Can read `Link` headers returned from snapshot actions * Optionally allow return or `Snapshot` objects from snapshot actions. Bug fixes: * Ignore select directories from version control. * Removed duplicate spec_helper * Addition of style rules using `rubocop` * Automated clean up of style rules * Be pessimistic about `inflecto` gem. Next release of Inflecto gem will introduce 1.9 constraint so we need to be pessimistic about the version to depend on for now. ### 0.6.1 / 2014-10-22 Bug fixes: * Fixes reading from `Server#ssl3?` ### 0.6.0 / 2014-10-21 Enhancements: * Allow setting of Load Balancer SSL v3 parameter when creating or updating. ### 0.5.1 / 2014-09-15 Bug fixes: * Fix a possible authentication loop when bad credentials or expired tokens would trigger repeated attempts to authenticate with no changes to the bad credentials. ### 0.5.0 / 2014-09-01 Enhancements: * Allow setting of Load Balancer buffer sizes during create and update calls. ### 0.4.1 / 2014-08-28 Bug fixes: * Default updated to final hostname of `orbit.brightbox.com`. ### 0.4.0 / 2014-08-28 Enhancements: * Add Add support for Brightbox Orbit cloud storage service. This adds a `storage` service to the Brightbox provider using the standard `fog` interfaces. ### 0.3.0 / 2014-08-12 Enhancements: * Use improved reset and reboot requests for the `Server#reboot` method allowing requests without having to fake restarts with a start/stop. This keeps the VNC console active. ### 0.2.0 / 2014-08-07 Enhancements: * Add resource locks to prevent accidental deleting of the following resources: * Database servers * Database snapshots * Images * Load balancers * Servers ### 0.1.1 / 2014-06-26 Bug fixes: * Fix `list_events` options to have workable defaults ### 0.1.0 / 2014-06-25 Enhancements: * Add `pry` as a development dependency so available under Bundler * Add `spec_helper` to DRY out requires on start of tests * Add `Fog::Brightbox::Model` layer to add shared functionality between models * Add `#resource_name` and `#collection_name` inflection methods to models * Add basic specs for models Changes: * Update generated documentation for requests Bug fixes: * Fix `rake:spec` task to add "spec" to LOAD_PATH ### 0.1.0.dev2 / 2014-04-22 This PRERELEASE version may contain functionality that may be removed before the next release so all APIs should be considered unstable and you should lock to the exact version if used! Bug fixes: * Reference fog-core-v1.22 rather than "master" branch now it is released. ### 0.1.0.dev1 / 2014-04-10 Enhancements: * Add support for events feed ### 0.0.2 / 2014-04-10 Bug fixes: * Add CHANGELOG.md to `fog-brightbox` module. * Add MiniTest::Specs to project. Use `rake test` to check the code. * Add Gemfile, Rakefile, README and LICENCE to start documenting project. * Remove redundant calls to `Fog.credentials`. The code flow was such that the credentials were being passed in to `Fog::Compute::Brightbox` anyway. * Isolate testing from contents of `~.fog` file which is leaking in throug the `Fog.credentials` global. ### 0.0.1 / 2014-02-19 Enhancements: * Initial release of extracted `fog-brightbox` module. This is pretty much the pilot for fog modules so bear with us as we iron out the bugs. fog-brightbox-0.7.1/README.md0000644000004100000410000000261012464011624015566 0ustar www-datawww-data# Brightbox Cloud module for fog (The Ruby cloud services library) This gem is a module for the `fog` gem that allows you to manage resources in the Brightbox Cloud. It is included by the main `fog` metagem but can used as an independent library in other applications. This includes support for the following services: * Compute * Images * Load Balancers * SQL Cloud instances Currently all services are grouped within `compute` but will be moved to their own sections when standardisation of fog progresses. ## Installation Add this line to your application's Gemfile: gem "fog-brightbox" And then execute: $ bundle Or install it yourself as: $ gem install fog-brightbox ## Usage Please see the following references for instructions using the main `fog` gem and its modules: * https://github.com/fog/fog * http://fog.io/ * http://rubydoc.info/gems/fog/ ### Ruby 1.8.7 If you are still using Ruby 1.8.7 in production, see `gemfiles/Gemfile.1.8.7` for a gemfile of 1.8.7 compatible version of dependencies you may need to specify in your application's `Gemfile` ## Contributing `fog` modules are kept within the main repo. 1. Fork it ( http://github.com/fog/fog/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request