Sunbird dcTrack API client in Python
Project description
dcTrackClient
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 quicksearch(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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for dctrackclient-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16f6c4c229daa2a46ec0b61129357d4e0dbdb077d3b5ceab15a1f0c3542cecdb |
|
MD5 | 6b91e27bf5a0c88a3200108c8f84cfb6 |
|
BLAKE2b-256 | bbd26ef5f1de33019969cc38848e50a3985bc475e89e191d18c15bcbe066ca15 |