diff --git a/lib/fog/brightbox/compute.rb b/lib/fog/brightbox/compute.rb index 63a59b742..20455a7af 100644 --- a/lib/fog/brightbox/compute.rb +++ b/lib/fog/brightbox/compute.rb @@ -24,6 +24,8 @@ module Fog model :account collection :applications model :application + collection :api_clients + model :api_client collection :servers model :server collection :server_groups diff --git a/lib/fog/brightbox/models/compute/api_client.rb b/lib/fog/brightbox/models/compute/api_client.rb new file mode 100644 index 000000000..cf2954099 --- /dev/null +++ b/lib/fog/brightbox/models/compute/api_client.rb @@ -0,0 +1,37 @@ +module Fog + module Compute + class Brightbox + class ApiClient < Fog::Model + identity :id + attribute :name + attribute :description + attribute :secret + attribute :revoked_at, :type => :time + attribute :account_id + + def save + raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity + options = { + :name => name, + :description => description + }.delete_if {|k,v| v.nil? || v == "" } + data = connection.create_api_client(options) + merge_attributes(data) + true + end + + def destroy + requires :identity + connection.destroy_api_client(identity) + true + end + + def reset_secret + requires :identity + connection.reset_secret_api_client(identity) + true + end + end + end + end +end diff --git a/lib/fog/brightbox/models/compute/api_clients.rb b/lib/fog/brightbox/models/compute/api_clients.rb new file mode 100644 index 000000000..33ded8a33 --- /dev/null +++ b/lib/fog/brightbox/models/compute/api_clients.rb @@ -0,0 +1,24 @@ +require "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 = connection.list_api_clients + load(data) + end + + def get(identifier = nil) + data = connection.get_api_client(identifier) + new(data) + rescue Excon::Errors::NotFound + nil + end + end + end + end +end