Module: Conjur::Exists

Included in:
Host, Resource, Role
Defined in:
lib/conjur/exists.rb

Instance Method Summary collapse

Instance Method Details

#exists?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/conjur/exists.rb', line 3

def exists?(options = {})
  begin
    self.head(options)
    true
  rescue RestClient::Forbidden
    # rationale is: exists? should return true iff creating a resource with
    # the same name would fail (not by client's fault). Why it would fail
    # doesn't matter that much.
    # (Plus, currently it always 403s when the resource exists but is unaccessible.)
    true
  rescue RestClient::ResourceNotFound
    false
  end
end