Submit a ticketCall us

WebinarUpcoming Webinar: How Help Desk and Remote Support Pays for Itself

Learn how help desk software can simplify ticketing management, allow you to track hardware and software assets, and accelerate the speed of IT support and service delivery. Gain insights on how remote support tools allow your IT team to maximize their efficiency and ticket resolution by expediting desktop troubleshooting, ultimately helping keep end-users happy and productive.

Register here.

Home > Success Center > Kiwi CatTools > Kiwi CatTools Documentation > Kiwi CatTools 3.11 Administrator Guide > API > CatTools API Classes > CatTools Device class > Sample code for using the CatTools API Device object

Sample code for using the CatTools API Device object

Table of contents
No headers
Created by Caroline Juszczak, last modified by Caroline Juszczak on Jun 28, 2016

Views: 221 Votes: 0 Revisions: 1

Sample VB code showing you how to use the Device object of the CatTools API to add, edit or delete an entry in the database.

 

Add

Dim DB As CatToolsAPI.Database

Dim Device As CatToolsAPI.Device

 

Set DB = New CatToolsAPI.Database

If DB.OpenConnection Then

Set Device = DB.Devices.AddNew("Cisco.Router.General")

If Not Device Is Nothing Then

Device.Name = "My Device 01"

Device.HostAddress = "192.168.1.1"

Device.Group = "My Test Group"

Device.RequireVTYLogin = True

Device.VTYPass = "My Password"

Device.ConnectionMethod = "Telnet"

If DB.Devices.SaveDevice(Device) Then

Debug.Print Device.Name & " saved to the database OK."

Else

Debug.Print "Adding " & Device.Name & " failed: " & DB.ErrDescription

End If

Else

Debug.Print "Creation of a new device failed: " & DB.ErrDescription

End If

Else

Debug.Print "DB connection failed: " & DB.ErrDescription

End If

 

Set Device = Nothing

Set DB = Nothing

 

Edit

Dim DB As CatToolsAPI.Database

Dim Devices As CatToolsAPI.Devices

Dim Device As CatToolsAPI.Device

 

Set DB = New CatToolsAPI.Database

If DB.OpenConnection Then

Set Devices = DB.Devices

Set Device = Devices.GetByName("My Device 01")

If Not Device Is Nothing Then

Debug.Print Device.Name & " Loaded OK"

Device.AAAPassword = "My New Password "

If Devices.SaveDevice(Device) Then

Debug.Print ??Device.Name & " saved OK"

Else

Debug.Print Device.Name & " NOT saved: " & DB.ErrDescription

End If

Else

Debug.Print "Device not found"

End If

Else

Debug.Print "DB connection failed: " & DB.ErrDescription

End If

 

Set Device = Nothing

Set Devices = Nothing

Set DB = Nothing

 

Delete

Dim DB As CatToolsAPI.Database

 

Set DB = New CatToolsAPI.Database

If DB.OpenConnection Then

If DB.Devices.DeleteByName("My Device 01") Then

Debug.Print "Deleted OK"

Else

Debug.Print "Delete failed: " & DB.ErrDescription

End If

Else

Debug.Print "DB connection failed: " & DB.ErrDescription

End If

 

Set DB = Nothing

Last modified

Tags

Classifications

Public