5.2. ライフサイクル環境の操作
Satellite は、アプリケーションのライフサイクルを、ライフサイクル環境に分割します。ライフサイクル環境は、アプリケーションのライフサイクルの各ステージを表します。ライフサイクル環境は、環境パスからリンクされます。リンクされたライフサイクル環境を API で作成するには、prior_id パラメーターを使用します。
https://satellite.example.com/apidoc/v2/lifecycle_environments.html で、ライフサイクル環境に関する、同梱の API リファレンスを確認できます。API ルートには /katello/api/environments および /katello/api/organizations/:organization_id/environments が含まれます。
5.2.1. ライフサイクル環境の一覧表示 リンクのコピーリンクがクリップボードにコピーされました!
以下の API 呼び出しを使用して、Satellite にある ID が 1 のデフォルトの組織に対する現在の全ライフサイクル環境を表示します。
API 要求
$ curl \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--request GET \
--user My_User_Name:My_Password \
https://satellite.example.com/katello/api/organizations/1/environments \
| python3 -m json.tool`
API 応答
output omitted
"description": null,
"id": 1,
"label": "Library",
"library": true,
"name": "Library",
"organization": {
"id": 1,
"label": "Default_Organization",
"name": "Default Organization"
},
"permissions": {
"destroy_lifecycle_environments": false,
"edit_lifecycle_environments": true,
"promote_or_remove_content_views_to_environments": true,
"view_lifecycle_environments": true
},
"prior": null,
"successor": null,
output truncated
5.2.2. ライフサイクル環境のリンク作成 リンクのコピーリンクがクリップボードにコピーされました!
以下の例を使用して、ライフサイクル環境のパスを作成します。以下の手順では、ID が 1 のデフォルトのライブラリー環境が、ライフサイクル環境作成の開始点として使用されています。
API の手順
開始点として使用する既存のライフサイクル環境を選択します。ID を使用して環境を表示します。この場合、ID が
1の環境は以下のようになります。要求例:
$ curl \ --request GET \ --user My_User_Name:My_Password \ https://satellite.example.com/katello/api/environments/1 \ | python3 -m json.tool応答例:
output omitted "id": 1, "label": "Library", output omitted "prior": null, "successor": null, output truncated以下のコンテンツを含めて、
life-cycle.jsonなどの JSON ファイルを作成します。{"organization_id":1,"label":"api-dev","name":"API Development","prior":1}priorオプションを1に設定してライフサイクル環境を作成します。要求例:
$ curl \ --header "Accept:application/json" \ --header "Content-Type:application/json" \ --request POST \ --user My_User_Name:My_Password \ --data @life-cycle.json \ https://satellite.example.com/katello/api/environments \ | python3 -m json.tool応答例:
output omitted "description": null, "id": 2, "label": "api-dev", "library": false, "name": "API Development", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 1, "name": "Library" }, output truncatedコマンド出力では、このライフサイクル環境の ID が
2であり、その 1 つ前のライフサイクル環境が1であることがわかります。ID が2のライフサイクル環境を使用して、この環境の後継を作成します。以前作成した
life-cycle.jsonファイルを編集して、label、name、priorの値を更新します。{"organization_id":1,"label":"api-qa","name":"API QA","prior":2}priorオプションを2に設定して、ライフサイクル環境を作成します。要求例:
$ curl \ --header "Accept:application/json" \ --header "Content-Type:application/json" \ --request POST \ --user My_User_Name:My_Password \ --data @life-cycle.json \ https://satellite.example.com/katello/api/environments \ | python3 -m json.tool応答例:
output omitted "description": null, "id": 3, "label": "api-qa", "library": false, "name": "API QA", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 2, "name": "API Development" }, "successor": null, output truncatedコマンド出力では、ライフサイクル環境の ID が
3で、ライフサイクル環境は2であると分かります。
5.2.3. ライフサイクル環境の更新 リンクのコピーリンクがクリップボードにコピーされました!
PUT コマンドを使用してライフサイクル環境を更新できます。以下の要求例では、ID が 3 のライフサイクル環境の説明を更新します。
API 要求
$ curl \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--request POST \
--user My_User_Name:My_Password \
--data '{"description":"Quality Acceptance Testing"}' \
https://satellite.example.com/katello/api/environments/3 \
| python3 -m json.tool
API 応答
output omitted
"description": "Quality Acceptance Testing",
"id": 3,
"label": "api-qa",
"library": false,
"name": "API QA",
"organization": {
"id": 1,
"label": "Default_Organization",
"name": "Default Organization"
},
"permissions": {
"destroy_lifecycle_environments": true,
"edit_lifecycle_environments": true,
"promote_or_remove_content_views_to_environments": true,
"view_lifecycle_environments": true
},
"prior": {
"id": 2,
"name": "API Development"
},
output truncated
5.2.4. ライフサイクル環境の削除 リンクのコピーリンクがクリップボードにコピーされました!
後継がない場合はライフサイクル環境を削除できます。このような理由から、以下の形式のコマンドを使用して、逆順にライフサイクル環境を削除します。
API 要求
$ curl \
--request DELETE \
--user My_User_Name:My_Password \
https://satellite.example.com/katello/api/environments/:id