Weitere ähnliche Inhalte
Ähnlich wie Redmineをちょっと便利に! プログラミング無しで使ってみるREST API (20)
Redmineをちょっと便利に! プログラミング無しで使ってみるREST API
- 19. {"users":
[{"id":1,"login":"admin","firstname":"Redmine","lastname":"Admin","mail"
07-19T17:12:21Z","last_login_on":"2018-05-
25T20:24:22Z","custom_fields":[{"id":4,"name":"Phone
number","value":""},{"id":5,"name":"Money","value":""}]},
{"id":3,"login":"dlopper","firstname":"Dave","lastname":"Lopper","mail":
07-19T17:33:19Z","custom_fields":[{"id":4,"name":"Phone
number","value":""},{"id":5,"name":"Money","value":""}]},
{"id":22,"login":"example","firstname":"Some","lastname":"One","mail":"s
05-24T13:40:12Z","custom_fields":[{"id":4,"name":"Phone
number","value":""},{"id":5,"name":"Money","value":""}]},
{"id":2,"login":"jsmith","firstname":"John","lastname":"Smith","mail":"j
07-19T17:32:09Z","last_login_on":"2006-07-
19T20:42:15Z","custom_fields":[{"id":4,"name":"Phone
number","value":"01 42 50 00 00"},{"id":5,"name":"Money","value":""}]},
18
- 21. {
"users": [
{
"id": 1,
"login": "admin",
"firstname": "Redmine",
"lastname": "Admin",
"mail": "admin@somenet.foo",
"created_on": "2006-07-19T17:12:21Z",
"last_login_on": "2018-05-25T20:33:44Z",
"custom_fields": [
{
"id": 4,
"name": "Phone number",
"value": ""
20
- 23. フォーマット: ログインID,メールアドレス,名,姓
"admin","admin@somenet.foo","Redmine","Admin"
"dlopper","dlopper@somenet.foo","Dave","Lopper"
"jsmith","jsmith@somenet.foo","John","Smith"
"miscuser8","miscuser8@foo.bar","User","Misc"
"miscuser9","miscuser9@foo.bar","User","Misc"
"rhill","rhill@somenet.foo","Robert","Hill"
"someone","someone@foo.bar","Some","One"
22
- 25. ユーザーをCSVから一括登録するユーザーをCSVから一括登録する
ファイル user.csv を用意して
実行
user0001,foo@example.com,Joe,Bloggs,HiaH4JJd
user0002,bar@example.com,Jane,Public,9iQYyLn5
user0003,baz@example.com,Chris,Wong,dG9EFggG
cat /tmp/users.csv | while read LINE
do
echo $LINE | jq -R 'gsub(""";"") | split(",") | {"user": {"login": .
[0], "mail": .[1], "firstname": .[2], "lastname": .[3], "password": .
[4]}}' | curl -v 'http://redmine.test/users.json' --user admin:
--header 'Content-type: application/json' --data @-
done
24
- 27. チケット操作チケット操作
#
curl http:// /issues.json --user ID:
#
curl http:// /issues/1.json --user ID:
#
curl http:// /issues.json --user ID: --header
'Content-type: application/json' --data '{"issue": {"project_id": 1,
"tracker_id": 1, "subject": " ", "description": " "}}'
#
curl http:// /issues/5.json --user ID: --request
'PUT' --header 'Content-type: application/json' --data '{"issue":
{"subject": " ", "description": " "}}'
#
curl http:// /issues/16.json --user ID: --request
'DELETE'
26
- 30. チケットを1行のテキストに変換チケットを1行のテキストに変換
コマンド
結果
curl --user ID: 'http://redmine.test/issues/1.json?
limit=100' | jq '.issue | "(.tracker.name) #(.id) - (.subject) (
(.status.name)) http://redmine.test/issues/(.id)" | @text'
Bug #1 - Cannot print recipes (New) http://redmine.test/issues/1
29
- 31. 開始日が今日以前のチケットを抽出開始日が今日以前のチケットを抽出
コマンド
結果
curl --user ID: "http://redmine.test/issues.json?
limit=100&start_date=<=`date +%Y-%m-%d`&sort=start_date" | jq -r
'.issues[] | "(.tracker["name"]) #(.id) - (.subject) (
(.start_date))" | @text'
Bug #3 - Error 281 when updating a recipe (2018-05-08)
Bug #7 - Issue due today (2018-05-13)
Feature request #2 - Add ingredients categories (2018-05-21)
Bug #1 - Cannot print recipes (2018-05-22)
Bug #6 - Issue of a private subproject (2018-05-23)
Bug #9 - Blocked Issue (2018-05-23)
Bug #10 - Issue Doing the Blocking (2018-05-23)
30
- 40. デバッグにはcurl のデバッグにはcurl の オプションが便利オプションが便利
ヘッダが見えるのでRedmineサーバとの通信で何が起こっているか把握しやすい
#
$ curl -v --user ID: "http://redmine.test/users.json"
.
( )
.
< HTTP/1.1 403 Forbidden
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< Content-Type: application/json
.
.
39