Package: clientcentral
clientcentral-api-pythonInstallpipinstallclientcentral--userUpgradingpipinstall--user--upgradeclientcentralA specific version can also be installed by adding the tag:pipinstall--user--upgradeclientcentral==12.5.6RequirementsThis library was built and tested onPython 3.11a minimal Python version ofPython 3.7.xis required.Python 2is not supported.FeaturesObject Oriented APIQueryingLazy loading (Events)ConfigThe token that will be used can either be sent as an environement variable:CC_TOKEN=<TOKEN>python3main.pyor parsed to the constructor:cc=ClientCentral(production=True,token="123")Example usageimportclientcentral.ticketformattingastffromclientcentral.clientcentralimportClientCentral# Production 'false' will run on qa.cccc=ClientCentral(production=True)# This will create a ticket in the Managed Services workspace.# In this example custom_fields {"id": 17, "values": 0} refer to "Security related" -> "No"# Theses values can be found by following the following instructions: https://clientcentral.io/support/cc/kb/articles/1661-tickets-api-creating-ticketsticket=cc.create_ticket(subject="New awesome subject",description="this is an awesome ticket",account_vp=1,customer_user_vp=1,project_id=8,workspace_id=16,custom_fields_attributes=[{"id":17,"values":0},{"id":75,"values":363}])ticket.comment("<p>"+tf.bold("I am BOLD")+"</p>")# Get the ticket's creatorprint("Ticket creator: "+ticket.owner.name)# Get the ticket's statusprint("Ticket status:"+ticket.status.name)# Print the ticket's descriptionprint("Ticket description: "+ticket.description)# Add a user to watchersticket.add_user_watcher(14012)# 14012 refers to the user id in this case its "Thomas Scholtz"# Change the description of the ticketticket.description="New and improved ticket description"# Finally after making all changes commit them.ticket.commit()forcommentinticket.comments:ifcomment.created_by_user:print("Comment from: "+comment.created_by_user.name+" says: "+comment.comment)# Ticket events, change_events and comments are lazy loaded.forchange_eventinticket.change_events:ifchange_event.created_by_user:print("Change by: "+str(change_event.created_by_user.name))forchangeinchange_event.changes:print("Changed: "+str(change.name)+" from: "+str(change.from_value)+" to: "+str(change.to_value))Example queryfromclientcentral.clientcentralimportClientCentralimportclientcentral.queryasoperators# Production 'false' will run on qa.clientcentral.iocc=ClientCentral(production=True)# This will return a list of all tickets that are:# open,# in workspace with id 87,# created by the user with the email 'thomas@labs.epiuse.com',# has not been updated since 2019-02-20,# subject contains 'New awesome subject'tickets=cc.query_tickets().filter_by(operators.and_(operators.statement("status.open"),operators.comparison("workspace_id","=","87"),operators.comparison("created_by_user.email","=","'thomas@labs.epiuse.com'"),operators.comparison("updated_at","<","'2019-02-20'"),operators.comparison("subject","CONTAINS","'New awesome subject'"))).all()forticketintickets:# Get the ticket's creatorprint("Ticket creator: "+ticket.owner.name)# Get the ticket's statusprint("Ticket status:"+ticket.status.name)# Print the ticket's descriptionprint("Ticket description: "+ticket.description)# Ticket events, change_events and comments are lazy loaded.forcommentinticket.comments:ifcomment.created_by_user:print("Comment from: "+comment.created_by_user.name+" says: "+comment.comment)forchange_eventinticket.change_events:ifchange_event.created_by_user:print("Change by: "+str(change_event.created_by_user.name))forchangeinchange_event.changes:print("Changed: "+str(change.name)+" from: "+str(change.from_value)+" to: "+str(change.to_value))ContributingFor this repository we are enforcing the use ofCommitizen. Respective merge requests require to follow the format created fromCommitizen. More info can be found at:http://commitizen.github.io/cz-cli/