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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file dctrackclient-0.2.4.tar.gz.

File metadata

  • Download URL: dctrackclient-0.2.4.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for dctrackclient-0.2.4.tar.gz
Algorithm Hash digest
SHA256 e1825e164652514a2e57b0ef5b895f87b1a3ebbca527f48fd74a7b378e29185b
MD5 9ccebb7c50d73991ded75ae3ae1446ab
BLAKE2b-256 456d3b31697508287060f99daa9135500eef3ef8b705d0f0b796bb67a7881c8c

See more details on using hashes here.

File details

Details for the file dctrackclient-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: dctrackclient-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for dctrackclient-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6722cc593baa6ec25a0b121b6297e7a073daa8810d2289f3801d38a7b1e3bef2
MD5 1298475e29edd299e44e2cb41c462f77
BLAKE2b-256 117ba91fabf5e390faed03814464644bee1c93ff35eceece844dd89596905a36

See more details on using hashes here.

Supported by

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