2012-09-21 08:42:40 -04:00
|
|
|
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
|
2012-12-22 21:45:05 -05:00
|
|
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
2012-09-21 08:42:40 -04:00
|
|
|
options = {
|
|
|
|
:name => name,
|
|
|
|
:description => description
|
|
|
|
}.delete_if {|k,v| v.nil? || v == "" }
|
2012-12-22 18:29:21 -05:00
|
|
|
data = service.create_api_client(options)
|
2012-09-21 08:42:40 -04:00
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :identity
|
2012-12-22 18:29:21 -05:00
|
|
|
service.destroy_api_client(identity)
|
2012-09-21 08:42:40 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def reset_secret
|
|
|
|
requires :identity
|
2012-12-22 18:29:21 -05:00
|
|
|
service.reset_secret_api_client(identity)
|
2012-09-21 08:42:40 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|