@@ -16,6 +16,18 @@ def get_choices(self, choice_id=None):
16
16
def get_tenants (self , ** kwargs ):
17
17
"""Returns the tenants"""
18
18
return self .netbox_con .get ('/tenancy/tenants/' , ** kwargs )
19
+
20
+ def get_contacts (self , ** kwargs ):
21
+ """Returns the contacts"""
22
+ return self .netbox_con .get ('/tenancy/contacts/' , ** kwargs )
23
+
24
+ def get_contact_assignments (self , ** kwargs ):
25
+ """Returns the contacts"""
26
+ return self .netbox_con .get ('/tenancy/contact-assignments/' , ** kwargs )
27
+
28
+ def get_contact_roles (self , ** kwargs ):
29
+ """Returns the roles for contacts"""
30
+ return self .netbox_con .get ('/tenancy/contact-roles/' , ** kwargs )
19
31
20
32
def create_tenant (self , name , slug , ** kwargs ):
21
33
"""Create a new tenant
@@ -27,6 +39,32 @@ def create_tenant(self, name, slug, **kwargs):
27
39
"""
28
40
required_fields = {"name" : name , "slug" : slug }
29
41
return self .netbox_con .post ('/tenancy/tenants/' , required_fields , ** kwargs )
42
+
43
+ def create_contact (self , name : str , ** kwargs ):
44
+ """Create a new contact
45
+
46
+ :param name: Contact name
47
+ :param kwargs: optional fields
48
+ :return: netbox object if successful otherwise exception raised
49
+ """
50
+ required_fields = {"name" : name }
51
+ return self .netbox_con .post ('/tenancy/contacts/' , required_fields , ** kwargs )
52
+
53
+ def create_contact_assignment_tenant (self , contact_id : int , tenant_id : int , role_id : int , ** kwargs ):
54
+ """Connect a contect to a tenant
55
+
56
+ :param contact_display_name: Contact display name
57
+ :param tenant_id: The ID of the tenant
58
+ :param kwargs: optional fields
59
+ :return: netbox object if successful otherwise exception raised
60
+ """
61
+ required_fields = {
62
+ "content_type" : "tenancy.tenant" ,
63
+ "object_id" : tenant_id ,
64
+ "contact" : contact_id ,
65
+ "role" : role_id
66
+ }
67
+ return self .netbox_con .post ('/tenancy/contact-assignments/' , required_fields , ** kwargs )
30
68
31
69
def delete_tenant (self , tenant_name ):
32
70
"""Delete tenant
0 commit comments