Module: Legion::Extensions::Nautobot::Runners::Tenancy

Includes:
Helpers::Lex, Helpers::Client
Included in:
Client
Defined in:
lib/legion/extensions/nautobot/runners/tenancy.rb

Instance Method Summary collapse

Methods included from Helpers::Client

#connection

Instance Method Details

#create_tenant(url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



54
55
56
57
58
59
# File 'lib/legion/extensions/nautobot/runners/tenancy.rb', line 54

def create_tenant(url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).post('/api/tenancy/tenants/', attrs)
  resp.body
end

#create_tenant_group(url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



23
24
25
26
27
28
# File 'lib/legion/extensions/nautobot/runners/tenancy.rb', line 23

def create_tenant_group(url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).post('/api/tenancy/tenant-groups/', attrs)
  resp.body
end

#delete_tenant(id:, url: nil, token: nil, read_only: false) ⇒ Object

Raises:



68
69
70
71
72
# File 'lib/legion/extensions/nautobot/runners/tenancy.rb', line 68

def delete_tenant(id:, url: nil, token: nil, read_only: false, **)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  connection(url: url, token: token).delete("/api/tenancy/tenants/#{id}/")
end

#delete_tenant_group(id:, url: nil, token: nil, read_only: false) ⇒ Object

Raises:



37
38
39
40
41
# File 'lib/legion/extensions/nautobot/runners/tenancy.rb', line 37

def delete_tenant_group(id:, url: nil, token: nil, read_only: false, **)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  connection(url: url, token: token).delete("/api/tenancy/tenant-groups/#{id}/")
end

#get_tenant(id:, url: nil, token: nil) ⇒ Object



49
50
51
52
# File 'lib/legion/extensions/nautobot/runners/tenancy.rb', line 49

def get_tenant(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/tenancy/tenants/#{id}/")
  resp.body
end

#get_tenant_group(id:, url: nil, token: nil) ⇒ Object



18
19
20
21
# File 'lib/legion/extensions/nautobot/runners/tenancy.rb', line 18

def get_tenant_group(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/tenancy/tenant-groups/#{id}/")
  resp.body
end

#list_tenant_groups(url: nil, token: nil, **params) ⇒ Object

Tenant Groups



13
14
15
16
# File 'lib/legion/extensions/nautobot/runners/tenancy.rb', line 13

def list_tenant_groups(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/tenancy/tenant-groups/', params)
  resp.body
end

#list_tenants(url: nil, token: nil, **params) ⇒ Object

Tenants



44
45
46
47
# File 'lib/legion/extensions/nautobot/runners/tenancy.rb', line 44

def list_tenants(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/tenancy/tenants/', params)
  resp.body
end

#update_tenant(id:, url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



61
62
63
64
65
66
# File 'lib/legion/extensions/nautobot/runners/tenancy.rb', line 61

def update_tenant(id:, url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).patch("/api/tenancy/tenants/#{id}/", attrs)
  resp.body
end

#update_tenant_group(id:, url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



30
31
32
33
34
35
# File 'lib/legion/extensions/nautobot/runners/tenancy.rb', line 30

def update_tenant_group(id:, url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).patch("/api/tenancy/tenant-groups/#{id}/", attrs)
  resp.body
end