ホストのリスト
get
/api/v2/hosts/
このリソースに対してGETリクエストを行って、ホストのリストを取得します。
結果のデータ構造には次が含まれます。
{
"count": 99,
"next": null,
"previous": null,
"results": [
...
]
}
count
フィールドは、対象となる問合せで見つかったホストの合計数を示します。 next
フィールドとprevious
フィールドには、結果が1ページに収まらない場合に、追加の結果へのリンクが表示されます。 results
リストには、0個以上のホスト・レコードが含まれます。
結果
それぞれのホスト・データ構造には次のフィールドが含まれます。
id
: このホストのデータベースID。(整数)type
: このホストのデータ型。(選択)url
: このホストのURL。(文字列)related
: 関連リソースのURLを含むデータ構造。(オブジェクト)summary_fields
: 関連リソースの名前/説明を含むデータ構造。 一部のオブジェクトの出力は、パフォーマンス上の理由によって制限される場合があります。(オブジェクト)created
: このホストが作成されたときのタイムスタンプ。(日時)modified
: このホストが最後に変更されたときのタイムスタンプ。(日時)name
: このホストの名前。(文字列)description
: このホストのオプションの説明。(文字列)inventory
: (id)enabled
: このホストがオンラインで、ジョブの実行に使用できるかどうか。(ブール)instance_id
: ホストを一意に識別するためにリモート・インベントリ・ソースによって使用される値(文字列)variables
: JSONまたはYAML形式のホスト変数。(json)has_active_failures
: (フィールド)has_inventory_sources
: (フィールド)last_job
: (id)last_job_host_summary
: (id)insights_system_id
: Red Hat Insightsのホストの一意識別子。(文字列)ansible_facts_modified
: ansible_factsが最後に変更された日時。(日時)
ソート
ホストが特定の順序で返されるように指定するには、GETリクエストでorder_by
問合せ文字列パラメータを使用します。
?order_by=name
フィールド名の先頭にダッシュ-
を付けると逆の順序でソートされます。
?order_by=-name
フィールド名をカンマ,
で区切ると、複数のソート・フィールドを指定できます。
?order_by=name,some_other_field
ページ区切り
リクエストごとに返される結果の数を変更するには、page_size
問合せ文字列パラメータを使用します。 特定のページの結果を取得するには、page
問合せ文字列パラメータを使用します。
?page_size=100&page=2
結果で返されるprevious
リンクおよびnext
リンクは、これらの問合せ文字列パラメータを自動的に設定します。
検索
モデルのすべての指定テキスト・フィールド内で大/小文字を区別しない検索を実行するには、search
問合せ文字列パラメータを使用します。
?search=findme
(Ansible Tower 3.1.0で追加)関連フィールド全体を検索します。
?related__search=findme
リクエスト
サポートされているメディア・タイプ
- application/json
問合せパラメータ
- page(オプション): 整数
ページ区切りが設定された結果セット内のページ番号。
- page_size(オプション): 整数
ページごとに返す結果の数。
- search(オプション): 文字列
検索条件。
レスポンス
サポートされているメディア・タイプ
- application/json
200レスポンス
レスポンスの例(application/json)
{
"count":20,
"next":"/api/v2/hosts/?page=3&page_size=5",
"previous":"/api/v2/hosts/?page=1&page_size=5",
"results":[
{
"ansible_facts_modified":null,
"created":"2018-02-01T08:00:00.000000Z",
"description":"",
"enabled":true,
"has_active_failures":false,
"has_inventory_sources":false,
"id":14,
"insights_system_id":null,
"instance_id":"",
"inventory":1,
"last_job":null,
"last_job_host_summary":null,
"modified":"2018-02-01T08:00:00.000000Z",
"name":"host-13",
"related":{
"activity_stream":"/api/v2/hosts/14/activity_stream/",
"ad_hoc_command_events":"/api/v2/hosts/14/ad_hoc_command_events/",
"ad_hoc_commands":"/api/v2/hosts/14/ad_hoc_commands/",
"all_groups":"/api/v2/hosts/14/all_groups/",
"ansible_facts":"/api/v2/hosts/14/ansible_facts/",
"groups":"/api/v2/hosts/14/groups/",
"insights":"/api/v2/hosts/14/insights/",
"inventory":"/api/v2/inventories/1/",
"inventory_sources":"/api/v2/hosts/14/inventory_sources/",
"job_events":"/api/v2/hosts/14/job_events/",
"job_host_summaries":"/api/v2/hosts/14/job_host_summaries/",
"smart_inventories":"/api/v2/hosts/14/smart_inventories/",
"variable_data":"/api/v2/hosts/14/variable_data/"
},
"summary_fields":{
"groups":{
"count":0,
"results":[
]
},
"inventory":{
"description":"",
"has_active_failures":false,
"has_inventory_sources":false,
"hosts_with_active_failures":0,
"id":1,
"inventory_sources_with_failures":0,
"kind":"",
"name":"test-inv",
"organization_id":1,
"total_groups":0,
"total_hosts":0,
"total_inventory_sources":0
},
"recent_jobs":[
],
"user_capabilities":{
"delete":true,
"edit":true
}
},
"type":"host",
"url":"/api/v2/hosts/14/",
"variables":""
},
{
"ansible_facts_modified":null,
"created":"2018-02-01T08:00:00.000000Z",
"description":"",
"enabled":true,
"has_active_failures":false,
"has_inventory_sources":false,
"id":15,
"insights_system_id":null,
"instance_id":"",
"inventory":1,
"last_job":null,
"last_job_host_summary":null,
"modified":"2018-02-01T08:00:00.000000Z",
"name":"host-14",
"related":{
"activity_stream":"/api/v2/hosts/15/activity_stream/",
"ad_hoc_command_events":"/api/v2/hosts/15/ad_hoc_command_events/",
"ad_hoc_commands":"/api/v2/hosts/15/ad_hoc_commands/",
"all_groups":"/api/v2/hosts/15/all_groups/",
"ansible_facts":"/api/v2/hosts/15/ansible_facts/",
"groups":"/api/v2/hosts/15/groups/",
"insights":"/api/v2/hosts/15/insights/",
"inventory":"/api/v2/inventories/1/",
"inventory_sources":"/api/v2/hosts/15/inventory_sources/",
"job_events":"/api/v2/hosts/15/job_events/",
"job_host_summaries":"/api/v2/hosts/15/job_host_summaries/",
"smart_inventories":"/api/v2/hosts/15/smart_inventories/",
"variable_data":"/api/v2/hosts/15/variable_data/"
},
"summary_fields":{
"groups":{
"count":0,
"results":[
]
},
"inventory":{
"description":"",
"has_active_failures":false,
"has_inventory_sources":false,
"hosts_with_active_failures":0,
"id":1,
"inventory_sources_with_failures":0,
"kind":"",
"name":"test-inv",
"organization_id":1,
"total_groups":0,
"total_hosts":0,
"total_inventory_sources":0
},
"recent_jobs":[
],
"user_capabilities":{
"delete":true,
"edit":true
}
},
"type":"host",
"url":"/api/v2/hosts/15/",
"variables":""
},
{
"ansible_facts_modified":null,
"created":"2018-02-01T08:00:00.000000Z",
"description":"",
"enabled":true,
"has_active_failures":false,
"has_inventory_sources":false,
"id":16,
"insights_system_id":null,
"instance_id":"",
"inventory":1,
"last_job":null,
"last_job_host_summary":null,
"modified":"2018-02-01T08:00:00.000000Z",
"name":"host-15",
"related":{
"activity_stream":"/api/v2/hosts/16/activity_stream/",
"ad_hoc_command_events":"/api/v2/hosts/16/ad_hoc_command_events/",
"ad_hoc_commands":"/api/v2/hosts/16/ad_hoc_commands/",
"all_groups":"/api/v2/hosts/16/all_groups/",
"ansible_facts":"/api/v2/hosts/16/ansible_facts/",
"groups":"/api/v2/hosts/16/groups/",
"insights":"/api/v2/hosts/16/insights/",
"inventory":"/api/v2/inventories/1/",
"inventory_sources":"/api/v2/hosts/16/inventory_sources/",
"job_events":"/api/v2/hosts/16/job_events/",
"job_host_summaries":"/api/v2/hosts/16/job_host_summaries/",
"smart_inventories":"/api/v2/hosts/16/smart_inventories/",
"variable_data":"/api/v2/hosts/16/variable_data/"
},
"summary_fields":{
"groups":{
"count":0,
"results":[
]
},
"inventory":{
"description":"",
"has_active_failures":false,
"has_inventory_sources":false,
"hosts_with_active_failures":0,
"id":1,
"inventory_sources_with_failures":0,
"kind":"",
"name":"test-inv",
"organization_id":1,
"total_groups":0,
"total_hosts":0,
"total_inventory_sources":0
},
"recent_jobs":[
],
"user_capabilities":{
"delete":true,
"edit":true
}
},
"type":"host",
"url":"/api/v2/hosts/16/",
"variables":""
},
{
"ansible_facts_modified":null,
"created":"2018-02-01T08:00:00.000000Z",
"description":"",
"enabled":true,
"has_active_failures":false,
"has_inventory_sources":false,
"id":17,
"insights_system_id":null,
"instance_id":"",
"inventory":1,
"last_job":null,
"last_job_host_summary":null,
"modified":"2018-02-01T08:00:00.000000Z",
"name":"host-16",
"related":{
"activity_stream":"/api/v2/hosts/17/activity_stream/",
"ad_hoc_command_events":"/api/v2/hosts/17/ad_hoc_command_events/",
"ad_hoc_commands":"/api/v2/hosts/17/ad_hoc_commands/",
"all_groups":"/api/v2/hosts/17/all_groups/",
"ansible_facts":"/api/v2/hosts/17/ansible_facts/",
"groups":"/api/v2/hosts/17/groups/",
"insights":"/api/v2/hosts/17/insights/",
"inventory":"/api/v2/inventories/1/",
"inventory_sources":"/api/v2/hosts/17/inventory_sources/",
"job_events":"/api/v2/hosts/17/job_events/",
"job_host_summaries":"/api/v2/hosts/17/job_host_summaries/",
"smart_inventories":"/api/v2/hosts/17/smart_inventories/",
"variable_data":"/api/v2/hosts/17/variable_data/"
},
"summary_fields":{
"groups":{
"count":0,
"results":[
]
},
"inventory":{
"description":"",
"has_active_failures":false,
"has_inventory_sources":false,
"hosts_with_active_failures":0,
"id":1,
"inventory_sources_with_failures":0,
"kind":"",
"name":"test-inv",
"organization_id":1,
"total_groups":0,
"total_hosts":0,
"total_inventory_sources":0
},
"recent_jobs":[
],
"user_capabilities":{
"delete":true,
"edit":true
}
},
"type":"host",
"url":"/api/v2/hosts/17/",
"variables":""
},
{
"ansible_facts_modified":null,
"created":"2018-02-01T08:00:00.000000Z",
"description":"",
"enabled":true,
"has_active_failures":false,
"has_inventory_sources":false,
"id":18,
"insights_system_id":null,
"instance_id":"",
"inventory":1,
"last_job":null,
"last_job_host_summary":null,
"modified":"2018-02-01T08:00:00.000000Z",
"name":"host-17",
"related":{
"activity_stream":"/api/v2/hosts/18/activity_stream/",
"ad_hoc_command_events":"/api/v2/hosts/18/ad_hoc_command_events/",
"ad_hoc_commands":"/api/v2/hosts/18/ad_hoc_commands/",
"all_groups":"/api/v2/hosts/18/all_groups/",
"ansible_facts":"/api/v2/hosts/18/ansible_facts/",
"groups":"/api/v2/hosts/18/groups/",
"insights":"/api/v2/hosts/18/insights/",
"inventory":"/api/v2/inventories/1/",
"inventory_sources":"/api/v2/hosts/18/inventory_sources/",
"job_events":"/api/v2/hosts/18/job_events/",
"job_host_summaries":"/api/v2/hosts/18/job_host_summaries/",
"smart_inventories":"/api/v2/hosts/18/smart_inventories/",
"variable_data":"/api/v2/hosts/18/variable_data/"
},
"summary_fields":{
"groups":{
"count":0,
"results":[
]
},
"inventory":{
"description":"",
"has_active_failures":false,
"has_inventory_sources":false,
"hosts_with_active_failures":0,
"id":1,
"inventory_sources_with_failures":0,
"kind":"",
"name":"test-inv",
"organization_id":1,
"total_groups":0,
"total_hosts":0,
"total_inventory_sources":0
},
"recent_jobs":[
],
"user_capabilities":{
"delete":true,
"edit":true
}
},
"type":"host",
"url":"/api/v2/hosts/18/",
"variables":""
}
]
}