Skip to main content

Sunbird dcTrack API client in Python

Project description

dcTrackClient GitHub Workflow Status PyPI PyPI - Downloads

Sunbird dcTrack API client in Python

Initialize a connection to the dcTrack API

Import the class:

from dcTrackClient import Client

Authenticate using a base URL (the same URL to access the GUI) and a username and password:

api = Client('https://dctrack.example.com/', username='user', password='pass')

Authenticate using a base URL and an API token:

api = Client('https://dctrack.example.com/', apiToken='asdf')

Usage Example

Create an item:

  • This example shows the minimum attributes required to create an item
  • See the official documentation for a comprehensive list of attributes
  • This function returns the JSON object for the newly created item
  • If it fails, the function will return a JSON object containing the error message
api.createItem({'cmbLocation': 'SAMPLE LOCATION', 'tiName': 'NEW-ITEM', 'cmbMake': 'Generic', 'cmbModel': 'Generic^Rackable^01'})

Retrieve item details:

item = api.getItem(1234)

Returns:

{
    "item": {
        ... // item attributes in here
    }
}

Modify an existing item:

api.modifyItem(1234, {'tiSerialNumber': 'SN-12345', 'tiAssetTag': 'DEV-12345'})

Delete an existing item:

api.deleteItem(1234)

Official DcTrack Documentation

Visit this link for the official documentation on request bodies and attrribute names.

https://www.sunbirddcim.com/help/dcTrack/v900/API/en/Default.htm

Module Documentation

class Client:

def __init__(self, baseUrl: str, username: str = '', password: str = '', apiToken: str = ''):

Provide either a username and password, or an API token to access the dcTrack database with Python.

def createItem(self, data: dict, returnDetails: bool = True):

Create a new item.

def modifyItem(self, id: int, data: dict, returnDetails: bool = True):

Update an existing item.

def deleteItem(self, id: int):

Delete an item using the item ID.

def getItem(self, id: int):

Get item details using the item ID.

def searchItems(self, data: dict, pageNumber: int, pageSize: int):

Search for items using criteria JSON object. Search criteria can be any of the fields applicable to items, including custom fields. Specify the fields to be included in the response. This API supports pagination.

def getCabinetItems(self, cabId: int):

Returns a list of Items contained in a Cabinet using the ItemID of the Cabinet. The returned list includes all of the Cabinet's Items including Passive Items.

def manageItemsBulk(self, cabId: int):

Retrieve a list of Items contained in a Cabinet including Passive Items.

def getAllMakes(self):

Retrieve a list of all Makes.

def addMake(self, data: dict):

Add a new Make.

def modifyMake(self, id: int, data: dict):

Modify a Make.

def deleteMake(self, id: int):

Delete a Make.

def getMakesByName(self, name: str, usingSpecialChars: bool = False):

Search for one or more makes using the make name. You also can search using special characters.

def getModel(self, id: int, usedCounts: bool = False):

Get Model fields for the specified Model ID.

def addModel(self, data: dict, returnDetails: bool = True, proceedOnWarning: bool = False):

Add a new Model.

def modifyModel(self, id: int, data: dict, returnDetails: bool = True, proceedOnWarning: bool = False):

Modify an existing Model.

def deleteModel(self, id: int):

Delete a Model using the Model ID.

def searchModels(self, data: dict, pageNumber: int, pageSize: int):

Search for models by user supplied search criteria.

def getConnector(self, id: int, usedCount: bool = False):

Get a Connector record by ID.

def addConnector(self, data: dict):

Add a new Connector.

def updateConnector(self, id: int, data: dict):

Update an existing Connector.

def deleteConnector(self, ids: list[int]):

Delete one or more Connector records.

def searchConnectors(self, data: dict, pageNumber: int, pageSize: int, usedCount: bool):

Retrieve a List of Connectors.

def createDataPorts(self, itemId: int, data: dict):

Use the REST API to create data ports for an existing item. If ports are already defined for the item because it is included in the Item Models Library, you can use the REST API to create additional ports for the item.

def updateDataPorts(self, itemId: int, portId: int, data: dict):

Update an item's data port details using the REST API. To do this, specify the item and data port ID, and provide the updated parameter value(s).

def deleteDataPorts(self, itemId: int, portId: int):

Delete an item's data port using the REST API by specifying the item ID and data port ID.

def getDataPorts(self, itemId: int):

Use the REST API to retrieve details from all data ports on an item.

def getDataPort(self, itemId: int, portId: int):

Use the REST API to read the details of an item's data port. To do this, specify the item and item data port ID.

def getPowerPorts(self, itemId: int):

Use the REST API to retrieve details from all power ports on an item.

def getPowerPort(self, itemId: int, portId: int):

Use the REST API to retrieve details from one power port on an item.

def updatePowerPort(self, itemId: int, portId: int, data: dict, proceedOnWarning: bool = True):

Use the REST API to create power ports for an existing item. If ports are already defined for the item because it is included in the Item Models Library, you can use the REST API to create additional ports for the item.

def compatibleConnector(self, itemId: int, portId: int, connectorId: int):

Use the REST API to determine if a Connector is compatible with a specific Power Port.

def getLocations(self):

Returns a list or all Locations.

def getLocation(self, id: int):

Get a single Location.

def addLocation(self, data: dict, proceedOnWarning: bool = False):

Add a Location.

def modifyLocation(self, id: int, data: dict, proceedOnWarning: bool = False):

Modify Location details for a single Location. Payload contains new location details. You do not have have to provide all details, but only those that you want to modify.

def deleteLocation(self, id: int):

Delete a Location.

def searchLocations(self, data: dict, pageNumber: int, pageSize: int):

Search for one or more Locations by user supplied search criteria.

def getLocationFieldList(self):

Returns a list of all Location fields.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dctrackclient-0.2.4.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

dctrackclient-0.2.4-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page