Cherwell REST API客户端和库

pycherwell的Python项目详细描述


PyPI versionapp

Cherwell API客户端

Cherwell API

入门

安装

如有必要,请升级pip

python3 -m pip install --upgrade pip setuptools wheel twine

使用PyPI安装:

^{pr2}$

从源安装:

git clone https://github.com/greenpau/pycherwell.git
cd pycherwell
pip3 install -r requirements.txt --user
python3 setup.py install --user --record installed_files.txt

如有必要,请卸载pycherwell

pip3 uninstall pycherwell
cat installed_files.txt | xargs sudo rm -rf

配置

LDAP配置文件:~/.cherwell/config

[default]client_id="5d4f6f1b-f0de-4442-8791-4582816b04de"auth_mode="LDAP"username="MYDOMAIN\myappuser"password="xxxxxx"host="myapp.cherwellondemand.com"port="443"protocol="https"

本地配置文件:~/.cherwell/config

[default]client_id="5d4f6f1b-f0de-4442-8791-4582816b04de"auth_mode="Internal"username="Cherwell\myappuser"password="xxxxxx"host="myapp.cherwellondemand.com"port="443"protocol="https"

测试

以下命令检查服务是否可用:

$ cherwell-client --get-service-info --debug

预期产出为:

{"service_info":{"api_version":"9.3.2","csm_culture":"en-US","csm_version":"9.3.2","system_date_time":"2019-11-18 18:14:42.510452+00:00"}}

使用说明

业务对象

以下命令获取业务对象摘要。它是指 业务对象本身的id、它们的字段、状态等

cherwell-client --get-business-object-summaries > business-object-summaries.json
{"business_object_summaries": [{"bus_ob_id": "fe838f7d1a8d4a748940dba7be76995c",
            "display_name": "Incident",
            "first_rec_id_field": "3910bef5813c421a92e4a68eea109a95",
            "group": false,
            "group_summaries": [],
            "lookup": false,
            "major": true,
            "name": "Incident",
            "rec_id_fields": "f5e8c54b647f48ad81e720132624001e",
            "state_field_id": "cb62a991a2cb4fd98cab26c3519b2d92",
            "states": "Pending,Closed,Reopened,New,In Progress,Resolved,Assigned",
            "supporting": false}]}

默认情况下,该工具将返回的业务对象存储在 ~/.cherwell/business_object.json。后续请求返回该文件的内容, 除非调用包含--rebase参数。在

cherwell-client --get-business-object-summaries --rebase

事件

搜索

以下命令返回“应用程序开发”团队拥有的事件:

cherwell-client --get-incidents --debug --search-condition "Owned By Team:eq:Application Development"

以下命令返回包含事件ID、类型和状态的CSV列表 “应用程序开发”团队所有“待定”项目:

cherwell-client --get-incidents \
  --search-condition "Status:eq:Pending"\
  --search-condition "Owned By Team:eq:Application Development"\
  --search-field "IncidentID" --search-field "IncidentType"\
  --search-field "Status" --format csv

以下命令返回未解析和未关闭项的CSV列表 对于“应用程序开发”团队:

cherwell-client --get-incidents \
  --search-condition "Owned By Team:eq:Application Development"\
  --search-condition "Status:eq:Pending"\
  --search-condition "Status:eq:Assigned"\
  --search-condition "Status:eq:In Progress"\
  --search-condition "Status:eq:New"\
  --search-field "IncidentID" --search-field "IncidentType" --search-field "Status"\
  --search-field "Service" --search-field "Category"  --search-field "Subcategory"\
  --search-field "Customer Display Name"\
  --search-field "Owned By"\
  --search-field "Created Date Time"\
  --search-field "Short Description"\
  --format csv

以下命令是上述命令的变体:

cherwell-client --get-incidents \
  --search-condition "Service:eq:Application Support"\
  --search-condition "Status:eq:Pending"\
  --search-condition "Status:eq:Assigned"\
  --search-condition "Status:eq:In Progress"\
  --search-condition "Status:eq:New"\
  --search-field "IncidentID" --search-field "IncidentType" --search-field "Status"\
  --search-field "Service" --search-field "Category"  --search-field "Subcategory"\
  --search-field "Customer Display Name"\
  --search-field "Owned By"\
  --search-field "Owned By Team"\
  --search-field "Created Date Time"\
  --search-field "Short Description"\
  --format csv

查询从特定日期开始的已关闭或已解决的事件,例如5/22/2020

cherwell-client --get-incidents \
  --search-condition "Service:eq:Application Support"\
  --search-condition "Status:eq:Closed"\
  --search-condition "Status:eq:Resolved"\
  --search-condition "Stat_DateTimeResolved:gt:5/22/2020 4:33 AM"\
  --search-field "IncidentID" --search-field "IncidentType" --search-field "Status"\
  --search-field "Service" --search-field "Category"  --search-field "Subcategory"\
  --search-field "Customer Display Name"\
  --search-field "Owned By"\
  --search-field "Owned By Team"\
  --search-field "Created Date Time"\
  --search-field "Short Description"\
  --format csv

查询过去7天内已关闭或已解决的事件:

cherwell-client --get-incidents \
  --search-condition "Service:eq:Application Support"\
  --search-condition "Status:eq:Closed"\
  --search-condition "Status:eq:Resolved"\
  --search-condition "Stat_DateTimeResolved:gt:7 days ago"\
  --search-field "IncidentID" --search-field "IncidentType" --search-field "Status"\
  --search-field "Service" --search-field "Category"  --search-field "Subcategory"\
  --search-field "Customer Display Name"\
  --search-field "Owned By"\
  --search-field "Owned By Team"\
  --search-field "Created Date Time"\
  --search-field "Short Description"\
  --format csv

以下命令返回有关Cherwell事件1234567的信息:

cherwell-client --get-incident 1234567 --debug --format yaml

创建

创建事件:

cherwell-client --create-incident \
  --create-field "ShortDescription:Review Pull Request #9 in App Repo"\
  --create-field "Priority:3"\
  --create-field "IncidentType:Incident"\
  --create-field "Service:Application Development"\
  --create-field "Category:Code Review"\
  --create-field "Subcategory:Other"\
  --create-as "FullName:eq:Smith, John"\
  --debug

创建服务请求:

cherwell-client --create-incident \
  --create-field "ShortDescription:Release app v1.0.0"\
  --create-field "Priority:3"\
  --create-field "IncidentType:Service Request"\
  --create-field "Service:Application Development"\
  --create-field "Category:Release Management"\
  --create-field "Subcategory:Release"\
  --create-as "FullName:eq:Smith, John"\
  --debug

预期产出为:

{"bus_ob_public_id":"293126","bus_ob_rec_id":"362965e244b242c5a3ba5a2b320baaa54632acf12b","cache_key":null,"error_code":null,"error_message":null,"field_validation_errors":[],"has_error":false,"notification_triggers":[]}

团队

获取团队列表:

^{pr21}$

人群

获取用户信息:

cherwell-client --get-requestors --search-condition "FullName:eq:Smith, John"
cherwell-client --get-requestors --search-condition "FirstName:eq:John" --search-condition "LastName:eq:Smith"

日志

以下命令输出事件1234567的日志条目:

cherwell-client --get-journal --incident-id 1234567 --format text

此外,日记账分录可以过滤:

cherwell-client --get-journal --incident-id 1234567 --format text \
  --search-condition "Journal Type Name:eq:Journal - Note"\
  --search-condition "Journal Type Name:eq:Journal - Customer Request"\
  --search-condition "Journal Type Name:eq:Journal - History"\
  --search-condition "Created Date Time:gt:7 days ago"

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java数据不显示在FXML表中   java如何使整个JTable不可编辑   Java中的swing JTree JTable组合   Windows下的java诊断NIO DatagramChannel读取问题   java Dockerfile运行可执行文件   java手动初始化字节数组以测试更改   java Selenium Webdriver | DragAndDrop功能|也不例外,但代码不起作用   java Hibernate使用多对多关系和左连接多次加载同一实体?   java正在努力开发带有接口和泛型集的API   mongodb mongo java条件和如果不为null   Java程序不显示使用arduino ethernet shield在网页上发送的数据   java将JSONObject转换为JSONArray错误   java Box布局可以接受包含元素的大小吗?