Cmd Execution

デバイスに対して任意のコマンドを実行し、実行結果を取得するAPIです。コマンドの実行を開始するとexec_idと呼ばれるIDが生成され、デバイスと共有されます。その後はexec_idを指定してコマンドの実行結果を取得することが可能です。

コマンド実行データのstatusパラメータには、現在のコマンドの実行状態が保存されています。statusは以下の3つの値を取ることができます。

  • executing: クライアントにコマンドを送信中・またはクライアントでの実行待ちです。
  • executed: コマンドの実行が完了し、結果が保存されている状態です。
  • error: 何らかのエラーが発生し、コマンドの実行自体が行えなかった状態です。最もよくあるのはデバイスが未接続の際にAPIをリクエストした時です。

またデバイスで実行されたコマンドが異常終了した場合はstatus=executedとなります。

POST Execute Command

指定したデバイスに対してコマンドの実行をリクエストします。
POST https://api.legs.iij.jp/api/devices/{device_id}/cmd_exec?token=api-token

Parameters

type parameter require example description
path device_id yes 02fcd662-5113-53d8-a118-747e81b99d03 デバイスID
query token yes api-token API Token

Request Body

{
  "command": "uname -a"
}

Response Body 201

show example

GET Get Command Result List

過去のコマンド実行結果をリストで取得します。取得時にページ数の指定が可能です。
GET https://api.legs.iij.jp/api/devices/{device_id}/cmd_exec?token=api-token&page=1&per_page=10

Parameters

type parameter require example description
path device_id yes 02fcd662-5113-53d8-a118-747e81b99d03 デバイスID
query token yes api-token API Token
query page no 1 ページ数の指定。デフォルト: 1
query per_page no 10 1ページあたりの表示数。デフォルト: 20

Response Body 200

show example

GET Get Single Command Result

`exec_id` を指定して特定のコマンド実行結果を取得します。
GET https://api.legs.iij.jp/api/devices/{device_id}/cmd_exec/{exec_id}?token=api-token

Parameters

type parameter require example description
path device_id yes 02fcd662-5113-53d8-a118-747e81b99d03 デバイスID
path exec_id yes CKP02THB8Rue6xTc exec_id
query token yes api-token API Token

Response Body 200

show example