Class: DIT3::Api::Wrappers::Tenants

Inherits:
Object
  • Object
show all
Defined in:
lib/dit3/api/wrappers/tenants.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Tenants

Returns a new instance of Tenants.



3
4
5
# File 'lib/dit3/api/wrappers/tenants.rb', line 3

def initialize client
    @client = client
end

Instance Method Details

#create(name) ⇒ Object



7
8
9
# File 'lib/dit3/api/wrappers/tenants.rb', line 7

def create name
    @client.post("/tenants", {'name' => name})
end

#exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/dit3/api/wrappers/tenants.rb', line 19

def exists? name
    !get(name).nil?
end

#get(name) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/dit3/api/wrappers/tenants.rb', line 11

def get name
    begin
        @client.get("/tenants/#{name}")
    rescue DIT3::Api::ApiError
        nil
    end
end