Class: Conjur::HostFactoryToken

Inherits:
RestClient::Resource
  • Object
show all
Includes:
HasAttributes
Defined in:
lib/conjur/host_factory_token.rb

Instance Method Summary collapse

Methods included from HasAttributes

#attributes, #invalidate, #refresh

Instance Method Details

#cidrObject



43
44
45
# File 'lib/conjur/host_factory_token.rb', line 43

def cidr
  attributes['cidr']
end

#expirationObject



35
36
37
# File 'lib/conjur/host_factory_token.rb', line 35

def expiration
  DateTime.iso8601(attributes['expiration'])
end

#host_factoryObject



39
40
41
# File 'lib/conjur/host_factory_token.rb', line 39

def host_factory
  Conjur::HostFactory.new(Conjur::API.host_factory_asset_host, options)[fully_escape attributes['host_factory']['id']]
end

#revoke!Object



47
48
49
50
51
# File 'lib/conjur/host_factory_token.rb', line 47

def revoke!
  invalidate do
    RestClient::Resource.new(self['revoke'].url, options).post
  end
end

#saveObject



53
54
55
# File 'lib/conjur/host_factory_token.rb', line 53

def save
  raise "HostFactoryToken attributes are not updatable"
end

#to_json(options = {}) ⇒ Object



25
26
27
# File 'lib/conjur/host_factory_token.rb', line 25

def to_json(options = {})
  { token: token, expiration: expiration, cidr: cidr }
end

#tokenObject Also known as: id



29
30
31
# File 'lib/conjur/host_factory_token.rb', line 29

def token
  self.url.split('/')[-1]
end