API使用例¶
[更新: 2023年12月06日]
「セキュアモバイルコネクト」関連のAPIの使用例です。
重要
- さくらのクラウドAPIの利用方法など、一般的な情報については APIドキュメント を参照ください。
- また、基本的なアプライアンスの操作については アプライアンス関連API をご参照ください。
- ご利用にはAPIキーが必要です。 APIキーの発行はコントロールパネルの APIキー管理 より行えます。
SIM関連¶
ヒント
- SIMのようなゾーン共通リソースのAPIは石狩第1ゾーン(is1a)のエンドポイントの利用を推奨します。
- コマンド中の $SAKURACLOUD_ZONEには特定のゾーン名(is1a,tk1aなど)を入力してください。
- コマンド中の $SIM_IDはSIMのリソースIDです。SIMのリソースIDは、 SIM詳細画面 から確認できます。
- コマンド中の $APPLIANCE_IDはモバイルゲートウェイのリソースIDです。モバイルゲートウェイのリソースIDは、 モバイルゲートウェイ詳細画面 から確認できます。
SIM一覧の取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem
レスポンス例
{
  "From": 0,
  "Count": 1,
  "Total": 1,
  "CommonServiceItems": [
    {
      "Index": 0,
      "ID": "xxxxxxxxxxxx",
      "Name": "example-sim",
      "Description": "example-desc",
      "Settings": null,
      "SettingsHash": null,
      "Status": {
        "ICCID": "898104xxxxxxxxxxxxx"
      },
      "ServiceClass": "cloud/sim/1",
      "Availability": "available",
      "CreatedAt": "2018-01-12T15:33:53+09:00",
      "ModifiedAt": "2018-01-12T15:33:53+09:00",
      "Provider": {
        "ID": 8000001,
        "Class": "sim",
        "Name": "sakura-sim",
        "ServiceClass": "cloud/sim"
      },
      "Icon": null,
      "Tags": []
    }
  ],
  "is_ok": true
}
SIM一覧の取得(SIM詳細付き)¶
Include を使うことによって、SIMの詳細情報を含めることができます。
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/ \
  --get \
  --data-urlencode '{"From":0,"Count":1,"Sort":["ID"],"Include":["*","Status.sim"],"Filter":{"Provider.Class":"sim"}}'
レスポンス例
{
  "From": 0,
  "Count": 1,
  "Total": 1,
  "CommonServiceItems": [
    {
      "Index": 0,
      "ID": "xxxxxxxxxxxx",
      "Name": "example-sim",
      "Description": "",
      "Settings": null,
      "SettingsHash": null,
      "Status": {
        "ICCID": "898104xxxxxxxxxxxxx",
        "sim": {
          "iccid": "898104xxxxxxxxxxxxx",
          "imsi": [
            "xxxxxxxxxxxxxxx"
          ],
          "ip": "192.168.0.11",
          "session_status": "DOWN",
          "imei_lock": false,
          "registered": true,
          "activated": true,
          "resource_id": "xxxxxxxxxxxx",
          "registered_date": "2018-01-12T06:33:54+00:00",
          "activated_date": "2018-01-12T08:20:16+00:00",
          "deactivated_date": "2018-01-12T08:20:08+00:00",
          "simgroup_id": "xxxxxxxxxxxx",
          "traffic_bytes_of_current_month": [],
          "connected_imei": ""
        }
      },
      "ServiceClass": "cloud/sim/1",
      "Availability": "available",
      "CreatedAt": "2018-01-12T15:33:53+09:00",
      "ModifiedAt": "2018-01-12T15:33:53+09:00",
      "Provider": {
        "ID": 8000001,
        "Class": "sim",
        "Name": "sakura-sim",
        "ServiceClass": "cloud/sim"
      },
      "Icon": null,
      "Tags": []
    }
  ],
  "is_ok": true
}
SIM一覧の取得(SIMの名前で検索)¶
Filterを用いて、SIMの名前を検索できます。
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/ \
  --get \
  --data-urlencode '{"Count":1,"Sort":["ID"],"Include":["*","Status.sim"],"Filter":{"Provider.Class":"sim", "Name": "example-sim"}}'
レスポンス例
{
  "From": 0,
  "Count": 1,
  "Total": 1,
  "CommonServiceItems": [
    {
      "Index": 0,
      "ID": "xxxxxxxxxxxx",
      "Name": "example-sim",
      "Description": "",
      "Settings": null,
      "SettingsHash": null,
      "Status": {
        "ICCID": "898104xxxxxxxxxxxxx",
        "sim": {
          "iccid": "898104xxxxxxxxxxxxx",
          "imsi": [
            "xxxxxxxxxxxxxxx"
          ],
          "ip": "192.168.0.11",
          "session_status": "DOWN",
          "imei_lock": false,
          "registered": true,
          "activated": true,
          "resource_id": "xxxxxxxxxxxx",
          "registered_date": "2018-01-12T06:33:54+00:00",
          "activated_date": "2018-01-12T08:20:16+00:00",
          "deactivated_date": "2018-01-12T08:20:08+00:00",
          "simgroup_id": "xxxxxxxxxxxx",
          "traffic_bytes_of_current_month": [],
          "connected_imei": ""
        }
      },
      "ServiceClass": "cloud/sim/1",
      "Availability": "available",
      "CreatedAt": "2018-01-12T15:33:53+09:00",
      "ModifiedAt": "2018-01-12T15:33:53+09:00",
      "Provider": {
        "ID": 8000001,
        "Class": "sim",
        "Name": "sakura-sim",
        "ServiceClass": "cloud/sim"
      },
      "Icon": null,
      "Tags": []
    }
  ],
  "is_ok": true
}
SIM情報の取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X GET \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID
レスポンス例
{
  "CommonServiceItem": {
    "ID": "xxxxxxxxxxxx",
    "Name": "example-sim",
    "Description": null,
    "Settings": null,
    "SettingsHash": null,
    "Status": {
      "ICCID": "898104xxxxxxxxxxxxx"
    },
    "ServiceClass": "cloud/sim/1",
    "Availability": "available",
    "CreatedAt": "2018-04-04T16:46:11+09:00",
    "ModifiedAt": "2018-04-04T16:46:11+09:00",
    "Provider": {
      "ID": 8000001,
      "Class": "sim",
      "Name": "sakura-sim",
      "ServiceClass": "cloud/sim"
    },
    "Icon": null,
    "Tags": []
  },
  "is_ok": true
}
SIMの状態の取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X GET \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/status
レスポンス例
{
  "sim": {
    "iccid": "898104xxxxxxxxxxxxx",
    "imsi": [
      "xxxxxxxxxxxxxxx"
    ],
    "session_status": "DOWN",
    "imei_lock": false,
    "registered": true,
    "activated": true,
    "resource_id": "xxxxxxxxxxxx",
    "registered_date": "2018-04-04T07:46:11+00:00",
    "activated_date": "2018-04-04T07:48:48+00:00",
    "deactivated_date": "2018-04-04T07:46:02+00:00",
    "traffic_bytes_of_current_month": {
      "uplink_bytes": 169734354,
      "downlink_bytes": 509606410
    },
    "connected_imei": "xxxxxxxxxxxxxxx"
  },
  "is_ok": true
}
SIMの作成¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X POST \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem \
  -d '{
  "CommonServiceItem": {
    "Name": "example-sim",
    "Status": {
      "ICCID": "898104xxxxxxxxxxxxx"
    },
    "Remark": {
      "PassCode": "xxxxxxxxxx"
    },
    "Provider": {
      "Class": "sim"
    }
  }
}'
レスポンス例
{
  "CommonServiceItem": {
    "ID": "xxxxxxxxxxxx",
    "Name": "example-sim",
    "Description": null,
    "Settings": null,
    "SettingsHash": null,
    "Status": {
      "ICCID": "898104xxxxxxxxxxxxx"
    },
    "ServiceClass": "cloud/sim/1",
    "Availability": "available",
    "CreatedAt": "2018-04-04T16:46:11+09:00",
    "ModifiedAt": "2018-04-04T16:46:11+09:00",
    "Provider": {
      "ID": 8000001,
      "Class": "sim",
      "Name": "sakura-sim",
      "ServiceClass": "cloud/sim"
    },
    "Icon": null,
    "Tags": []
  },
  "Success": true,
  "is_ok": true
}
エラーとなる設定例① (存在しないICCIDを指定する)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem \
  -d '{
  "CommonServiceItem": {
    "Name": "example-sim",
    "Status": {
      "ICCID": "notexistedsimiccid"
    },
    "Remark": {
      "PassCode": "xxxxxxxxxx"
    },
    "Provider": {
      "Class": "sim"
    }
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "404 Not Found",
  "error_code": "not_found",
  "error_msg": "不適切な要求です。パラメータの指定誤り、入力規則違反です。入力内容をご確認ください。\n対象が見つかりません。"
}
エラーとなる設定例② (パスコードが間違っている)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem \
  -d '{
  "CommonServiceItem": {
    "Name": "example-sim",
    "Status": {
      "ICCID": "898104xxxxxxxxxxxxx"
    },
    "Remark": {
      "PassCode": "invalidpass"
    },
    "Provider": {
      "Class": "sim"
    }
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "400 Bad Request",
  "error_code": "bad_request",
  "error_msg": "不適切な要求です。パラメータの指定誤り、入力規則違反です。入力内容をご確認ください。\nパスコードが正しくありません。"
}
エラーとなる設定例③ (登録済のSIMを指定している)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem \
  -d '{
  "CommonServiceItem": {
    "Name": "example-sim",
    "Status": {
      "ICCID": "898104xxxxxxxxxxxxx"
    },
    "Remark": {
      "PassCode": "xxxxxxxxxx"
    },
    "Provider": {
      "Class": "sim"
    }
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "409 Conflict",
  "error_code": "conflict",
  "error_msg": "要求された操作を行えません。現在の対象の状態では、この操作を受け付けできません。登録済です。"
}
エラーとなる設定例④ (ICCIDの桁数が間違っている)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem \
  -d '{
  "CommonServiceItem": {
    "Name": "example-sim",
    "Status": {
      "ICCID": "89810400000000000xxxxxxxxxxxxx"
    },
    "Remark": {
      "PassCode": "xxxxxxxxxx"
    },
    "Provider": {
      "Class": "sim"
    }
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "409 Conflict",
  "error_code": "conflict",
  "error_msg": "不適切な要求です。パラメータの指定誤り、入力規則違反です。入力内容をご確認ください。\nDoes not match the regex pattern \\A898104[0-9]{13}\\z\n"
}
SIMの有効化¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/activate
レスポンス例
{
  "is_ok": true
}
エラーとなる設定例① (存在しないSIMを有効化しようとする)¶
$SIM_ID に、SIM以外のリソースIDを指定した場合のエラーです
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/activate
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "404 Not Found",
  "error_code": "not_found",
  "error_msg": "対象が見つかりません。対象は利用できない状態か、IDまたはパスに誤りがあります。"
}
エラーとなる設定例② (有効化済のSIMを有効化しようとする)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/activate
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "409 Conflict",
  "error_code": "conflict",
  "error_msg": "要求された操作を行えません。現在の対象の状態では、この操作を受け付けできません。\n有効化済です。"
}
SIMの無効化¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/deactivate
レスポンス例
{
  "is_ok": true
}
SIMの再接続¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/reconnect
レスポンス例
{
  "is_ok": true
}
SIMの削除¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X DELETE \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID
レスポンス例
{
  "is_ok": true
}
SIMのキャリア設定を更新¶
全てのキャリアを有効化する¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/network_operator_config \
  -d '{
  "network_operator_config": [
    {
      "name": "SoftBank",
      "allow": true
    },
    {
      "name": "KDDI",
      "allow": true
    },
    {
      "name": "NTT DOCOMO",
      "allow": true
    }
  ]
}'
ヒント
キャリア指定の文字列は、 "SoftBank" 、 "KDDI" 、 "NTT DOCOMO" を指定してください。(大文字小文字を区別しますのでご注意ください)
レスポンス例
{
  "is_ok": true
}
実行結果
| キャリア | 設定 | 
|---|---|
| SoftBank | 有効 | 
| KDDI | 有効 | 
| NTT DOCOMO | 有効 | 
特定のキャリアのみ無効化する¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/network_operator_config \
  -d '{
  "network_operator_config": [
    {
      "name": "SoftBank",
      "allow": true
    },
    {
      "name": "KDDI",
      "allow": true
    },
    {
      "name": "NTT DOCOMO",
      "allow": false
    }
  ]
}'
ヒント
NTT DOCOMOのみを無効にする例です。
レスポンス例
{
  "is_ok": true
}
実行結果
| キャリア | 設定 | 
|---|---|
| SoftBank | 有効 | 
| KDDI | 有効 | 
| NTT DOCOMO | 無効 | 
特定のキャリアのみ有効化する¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/network_operator_config \
  -d '{
  "network_operator_config": [
    {
      "name": "SoftBank",
      "allow": true
    }
  ]
}'
ヒント
SoftBankのみを有効にする例です。
レスポンス例
{
  "is_ok": true
}
実行後の各キャリアの設定
| キャリア | 設定 | 
|---|---|
| SoftBank | 有効 | 
| KDDI | 無効 | 
| NTT DOCOMO | 無効 | 
注意
指定したキャリア以外の設定は、無効に変更されます。
エラーとなる設定例① (全てのキャリアを無効に設定)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/network_operator_config \
  -d '{
  "network_operator_config": [
    {
      "name": "SoftBank",
      "allow": false
    },
    {
      "name": "KDDI",
      "allow": false
    },
    {
      "name": "NTT DOCOMO",
      "allow": false
    }
  ]
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "400 Bad Request",
  "error_code": "bad_request",
  "error_msg": "不適切な要求です。パラメータの指定誤り、入力規則違反です。入力内容をご確認ください。\nネットワーク事業者設定が正しくありません。"
}
実行後の各キャリアの設定
| キャリア | 設定 | 
|---|---|
| SoftBank | 変更なし | 
| KDDI | 変更なし | 
| NTT DOCOMO | 変更なし | 
注意
エラーとなり、設定が変更されません。
エラーとなる設定例② (キャリア指定に間違いがある)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/network_operator_config \
  -d '{
  "network_operator_config": [
    {
      "name": "SoftBank",
      "allow": true
    },
    {
      "name": "KDDI",
      "allow": true
    },
    {
      "name": "NTT DoCoMo",
      "allow": true
    }
  ]
}'
ヒント
キャリア指定について、正しくは "NTT DOCOMO" と記載すべき箇所を "NTT DoCoMo" (大文字小文字間違い)とした例となります。
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "400 Bad Request",
  "error_code": "bad_request",
  "error_msg": "不適切な要求です。パラメータの指定誤り、入力規則違反です。入力内容をご確認ください。\nネットワーク事業者設定が正しくありません。"
}
実行後の各キャリアの設定
| キャリア | 設定 | 
|---|---|
| SoftBank | 変更なし | 
| KDDI | 変更なし | 
| NTT DOCOMO | 変更なし | 
注意
エラーとなり、設定が変更されません。
エラーとなる設定例③ (キャリア指定がない)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/network_operator_config \
  -d '{
  "network_operator_config": [
  ]
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "400 Bad Request",
  "error_code": "bad_request",
  "error_msg": "不適切な要求です。パラメータの指定誤り、入力規則違反です。入力内容をご確認ください。\nネットワーク事業者設定が正しくありません。"
}
実行後の各キャリアの設定
| キャリア | 設定 | 
|---|---|
| SoftBank | 変更なし | 
| KDDI | 変更なし | 
| NTT DOCOMO | 変更なし | 
注意
エラーとなり、設定が変更されません。
イレギュラーな設定例① (同じキャリアについて有効を2回指定してしまった場合)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/network_operator_config \
  -d '{
  "network_operator_config": [
    {
      "name": "SoftBank",
      "allow": true
    },
    {
      "name": "KDDI",
      "allow": true
    },
    {
      "name": "NTT DOCOMO",
      "allow": true
    },
    {
      "name": "NTT DOCOMO",
      "allow": true
    }
  ]
}'
ヒント
NTT DOCOMOの設定について、有効を2回指定してしまった場合の例となります。
レスポンス例
{
  "is_ok": true
}
実行後の各キャリアの設定
| キャリア | 設定 | 
|---|---|
| SoftBank | 有効 | 
| KDDI | 有効 | 
| NTT DOCOMO | 有効 | 
注意
同じキャリアについて有効を2回指定した場合は、エラーとならずに有効の設定となります。 
 (なお、同様に無効を2回指定した場合は、エラーとならずに無効の設定となります)
イレギュラーな設定例② (同じキャリアについて有効と無効を重複して指定してしまった場合)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/network_operator_config \
  -d '{
  "network_operator_config": [
    {
      "name": "SoftBank",
      "allow": true
    },
    {
      "name": "KDDI",
      "allow": true
    },
    {
      "name": "NTT DOCOMO",
      "allow": true
    },
    {
      "name": "NTT DOCOMO",
      "allow": false
    }
  ]
}'
ヒント
NTT DOCOMOの設定について、有効と無効を重複して指定してしまった例となります。(最初に有効を指定し次に無効を指定しています)
レスポンス例
{
  "is_ok": true
}
実行後の各キャリアの設定
| キャリア | 設定 | 
|---|---|
| SoftBank | 有効 | 
| KDDI | 有効 | 
| NTT DOCOMO | 有効 | 
注意
同じキャリアについて有効と無効を重複して指定した場合は、エラーとならずに有効の設定となります。 
 (最初に無効を指定し次に有効を指定した場合についても、エラーとならずに有効の設定となります)
SIMのキャリア設定を取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X GET \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/network_operator_config
レスポンス例
{
  "is_ok": true,
  "network_operator_config": [
    {
      "name": "SoftBank",
      "country_code": "JP",
      "allow": true
    },
    {
      "name": "KDDI",
      "country_code": "JP",
      "allow": true
    },
    {
      "name": "NTT DOCOMO",
      "country_code": "JP",
      "allow": true
    }
  ]
}
SIMのIPアドレスを設定¶
注意
IPアドレスの設定はモバイルゲートウェイに追加済のSIMに対してのみ行なえます。
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/ip \
  -d '{
  "sim": {
    "ip": "192.168.0.11"
  }
}'
レスポンス例
{
  "is_ok": true
}
エラーとなる設定例① (IPアドレスのフォーマットが不正)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/ip \
  -d '{
  "sim": {
    "ip": "192.168.1.0.0.0"
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "400 Bad Request",
  "error_code": "bad_request",
  "error_msg": "不適切な要求です。パラメータの指定誤り、入力規則違反です。入力内容をご確認ください。\nDoes not match the regex pattern \\A[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\z\n"
}
エラーとなる設定例② (プライベートIPアドレス以外のIPアドレスを指定)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/ip \
  -d '{
  "sim": {
    "ip": "203.0.113.1"
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "400 Bad Request",
  "error_code": "bad_request",
  "error_msg": "不適切な要求です。パラメータの指定誤り、入力規則違反です。入力内容をご確認ください。\nIPが正しくありません。"
}
エラーとなる設定例③ (さくらのクラウドへ未登録のSIMを指定)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/ip \
  -d '{
  "sim": {
    "ip": "192.168.10.1"
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "409 Conflict",
  "error_code": "conflict",
  "error_msg": "対象が見つかりません。対象は利用できない状態か、IDまたはパスに誤りがあります。"
}
エラーとなる設定例④ (モバイルゲートウェイに紐づいていないSIMを指定)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/ip \
  -d '{
  "sim": {
    "ip": "192.168.10.1"
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "404 Not Found",
  "error_code": "not_found",
  "error_msg": "対象が見つかりません。対象は利用できない状態か、IDまたはパスに誤りがあります。"
}
エラーとなる設定例⑤ (すでに紐づいているICCIDを指定)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/ip \
  -d '{
  "sim": {
    "ip": "192.168.10.1"
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "409 Conflict",
  "error_code": "conflict",
  "error_msg": "要求された操作を行えません。現在の対象の状態では、この操作を受け付けできません。\nIPを設定済です。"
}
エラーとなる設定例⑥ (モバイルゲートウェイ内での重複したIPアドレスを指定)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/ip \
  -d '{
  "sim": {
    "ip": "192.168.10.1"
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "400 Bad Request",
  "error_code": "bad_request",
  "error_msg": "不適切な要求です。パラメータの指定誤り、入力規則違反です。入力内容をご確認ください。\nIPが重複しています。"
}
SIMのIPアドレスを削除¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X DELETE \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/ip
レスポンス例
{
  "is_ok": true
}
SIMのIMEIを設定¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/imeilock \
  -d '{
  "sim": {
    "imei": "358916045692287"
  }
}'
レスポンス例
{
  "is_ok": true
}
SIMのIMEIを削除¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X DELETE \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/imeilock
レスポンス例
{
  "is_ok": true
}
SIMのセッションログの取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/sessionlog \
  --get \
  --data-urlencode '{"Count":2}'
レスポンス例
{
  "is_ok": true,
  "logs": [
    {
      "date": "2018-04-03T08:18:07+00:00",
      "session_status": "Created",
      "resource_id": "xxxxxxxxxxxx",
      "imei": "xxxxxxxxxxxxxxx",
      "imsi": "xxxxxxxxxxxxxxx"
    },
    {
      "date": "2018-04-03T08:17:29+00:00",
      "session_status": "Deleted",
      "resource_id": "xxxxxxxxxxxx",
      "imsi": "xxxxxxxxxxxxxxx"
    }
  ],
  "Count": 2
}
SIMのメトリクスの取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem/$SIM_ID/sim/metrics \
  --get \
  --data-urlencode '{"Start":"2018-04-04T12:00:00.000+09:00","End":"2018-04-04T13:00:00.000+09:00"}'
レスポンス例
{
  "is_ok": true,
  "Data": {
    "2018-04-04T12:00:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:05:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:10:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:15:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:20:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:25:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:30:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:35:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:40:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:45:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:50:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T12:55:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    },
    "2018-04-04T13:00:00+09:00": {
      "UplinkBps": 0,
      "DownlinkBps": 0
    }
  }
}
モバイルゲートウェイ関連¶
モバイルゲートウェイ一覧¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance \
  --get \
  --data-urlencode '{"Filter":{"Appliances.Class": "mobilegateway"}}'
レスポンス例
{
  "From": 0,
  "Count": 1,
  "Total": 1,
  "Appliances": [
    {
      "Index": 0,
      "ID": "xxxxxxxxxxxx",
      "Class": "mobilegateway",
      "Name": "example-mgw",
      "Description": "",
      "Plan": {
        "ID": 2
      },
      "Settings": {
        "MobileGateway": {
          "InternetConnection": {
            "Enabled": "True"
          },
          "Interfaces": [
            null,
            {
              "IPAddress": [
                "192.168.200.5"
              ],
              "NetworkMaskLen": 24
            }
          ],
          "StaticRoutes": [],
          "InterDeviceCommunication": {
            "Enabled": "False"
          }
        }
      },
      "SettingsHash": "719e0d10c3302fe7d886182bc82c38cb",
      "Remark": {
        "Servers": [
          []
        ],
        "Switch": {
          "Scope": "shared"
        },
        "Zone": {
          "ID": "30293"
        }
      },
      "Availability": "available",
      "Instance": {
        "Status": "up",
        "StatusChangedAt": "2018-03-22T22:32:02+09:00"
      },
      "ServiceClass": "cloud/appliance/mobilegateway/1",
      "CreatedAt": "2018-01-10T17:54:07+09:00",
      "Icon": null,
      "Switch": null,
      "Interfaces": [
        {
          "IPAddress": "133.242.32.y",
          "UserIPAddress": null,
          "HostName": null,
          "Switch": {
            "ID": "xxxxxxxxxxxx",
            "Name": "スイッチ",
            "Scope": "shared",
            "Subnet": {
              "NetworkAddress": "133.242.32.0",
              "NetworkMaskLen": 24,
              "DefaultRoute": "133.242.32.1",
              "Internet": {
                "BandWidthMbps": 100
              }
            },
            "UserSubnet": {
              "DefaultRoute": "133.242.32.1",
              "NetworkMaskLen": 24
            }
          }
        },
        {
          "IPAddress": null,
          "UserIPAddress": null,
          "HostName": null,
          "Switch": {
            "ID": "xxxxxxxxxxxx",
            "Name": "sw1",
            "Scope": "user",
            "Subnet": null,
            "UserSubnet": {
              "DefaultRoute": "192.168.200.1",
              "NetworkMaskLen": 24
            }
          }
        }
      ],
      "Tags": []
    }
  ],
  "is_ok": true
}
モバイルゲートウェイ情報の取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID
レスポンス例
{
  "Appliance": {
    "ID": "xxxxxxxxxxxx",
    "Class": "mobilegateway",
    "Name": "example-mgw",
    "Description": "",
    "Plan": {
      "ID": 2
    },
    "Settings": null,
    "SettingsHash": null,
    "Remark": {
      "Servers": [
        []
      ],
      "Switch": {
        "Scope": "shared"
      },
      "Zone": {
        "ID": "30293"
      }
    },
    "Availability": "available",
    "Instance": {
      "Status": "down",
      "StatusChangedAt": null
    },
    "ServiceClass": "cloud/appliance/mobilegateway/1",
    "CreatedAt": "2018-04-04T16:04:14+09:00",
    "Icon": null,
    "Switch": null,
    "Interfaces": [
      {
        "IPAddress": "133.242.32.y",
        "UserIPAddress": null,
        "HostName": null,
        "Switch": {
          "ID": "xxxxxxxxxxxx",
          "Name": "スイッチ",
          "Scope": "shared",
          "Subnet": {
            "NetworkAddress": "133.242.32.0",
            "NetworkMaskLen": 24,
            "DefaultRoute": "133.242.32.1",
            "Internet": {
              "BandWidthMbps": 100
            }
          },
          "UserSubnet": {
            "DefaultRoute": "133.242.32.1",
            "NetworkMaskLen": 24
          }
        }
      },
      null
    ],
    "Tags": []
  },
  "is_ok": true
}
モバイルゲートウェイの作成¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X POST \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance \
  -d '{
  "Appliance": {
    "Name": "example-mgw",
    "Class": "mobilegateway",
    "Plan": {
      "ID": 2
    },
    "Remark": {
      "Servers": [
        {}
      ],
      "Switch": {
        "Scope": "shared"
      }
    }
  }
}'
レスポンス例
{
  "Appliance": {
    "ID": "xxxxxxxxxxxx",
    "Class": "mobilegateway",
    "Name": "example-mgw",
    "Description": "",
    "Plan": {
      "ID": 2
    },
    "Settings": null,
    "SettingsHash": null,
    "Remark": {
      "Servers": [
        []
      ],
      "Switch": {
        "Scope": "shared"
      },
      "Zone": {
        "ID": "30293"
      }
    },
    "Availability": "migrating",
    "Instance": null,
    "ServiceClass": "cloud/appliance/mobilegateway/1",
    "CreatedAt": "2018-04-04T16:04:14+09:00",
    "Icon": null,
    "Switch": null,
    "Interfaces": [],
    "Tags": []
  },
  "Success": "Accepted",
  "ReturnCode": 0,
  "ResponseHeaders": {
    "Status": "Ok",
    "Cause": null
  },
  "Out": null,
  "is_ok": true
}
モバイルゲートウェイの設定を変更¶
注意
設定変更後には設定の反映が必要です。
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID \
  -d '{
  "Appliance": {
    "Settings": {
      "MobileGateway": {
        "Interfaces": [
          null,
          {
            "IPAddress": [
              "192.168.0.1"
            ],
            "NetworkMaskLen": 24
          }
        ],
        "InternetConnection": {
          "Enabled": "True"
        },
        "StaticRoutes": [
          {
            "Prefix": "172.16.1.0/24",
            "NextHop": "192.168.0.254"
          },
          {
            "Prefix": "172.16.2.0/24",
            "NextHop": "192.168.0.254"
          }
        ],
        "InterDeviceCommunication": {
          "Enabled": "True"
        }
      }
    }
  }
}'
レスポンス例
{
  "Appliance": {
    "ID": "xxxxxxxxxxxx",
    "Class": "mobilegateway",
    "Name": "example-mgw",
    "Description": "",
    "Plan": {
      "ID": 2
    },
    "Settings": {
      "MobileGateway": {
        "Interfaces": [
          null,
          {
            "IPAddress": [
              "192.168.0.1"
            ],
            "NetworkMaskLen": 24
          }
        ],
        "InternetConnection": {
          "Enabled": "True"
        },
        "StaticRoutes": [
          {
            "Prefix": "172.16.1.0/24",
            "NextHop": "192.168.0.254"
          },
          {
            "Prefix": "172.16.2.0/24",
            "NextHop": "192.168.0.254"
          }
        ],
        "InterDeviceCommunication": {
          "Enabled": "True"
        }
      }
    },
    "SettingsHash": "6dab2e7a0a47bdec844d36db79420b76",
    "Remark": {
      "Servers": [
        []
      ],
      "Switch": {
        "Scope": "shared"
      },
      "Zone": {
        "ID": "30293"
      }
    },
    "Availability": "available",
    "Instance": {
      "Status": "down",
      "StatusChangedAt": null
    },
    "ServiceClass": "cloud/appliance/mobilegateway/1",
    "CreatedAt": "2018-04-04T16:04:14+09:00",
    "Icon": null,
    "Switch": null,
    "Interfaces": [
      {
        "IPAddress": "133.242.32.y",
        "UserIPAddress": null,
        "HostName": null,
        "Switch": {
          "ID": "xxxxxxxxxxxx",
          "Name": "スイッチ",
          "Scope": "shared",
          "Subnet": {
            "NetworkAddress": "133.242.32.0",
            "NetworkMaskLen": 24,
            "DefaultRoute": "133.242.32.1",
            "Internet": {
              "BandWidthMbps": 100
            }
          },
          "UserSubnet": {
            "DefaultRoute": "133.242.32.1",
            "NetworkMaskLen": 24
          }
        }
      },
      null
    ],
    "Tags": []
  },
  "Success": true,
  "ReturnCode": 0,
  "ResponseHeaders": {
    "Status": "Ok",
    "Cause": null
  },
  "Out": null,
  "is_ok": true
}
モバイルゲートウェイの設定を反映¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/config
レスポンス例
{
  "Success": true,
  "ReturnCode": 0,
  "ResponseHeaders": {
    "Status": "Ok",
    "Cause": null
  },
  "Out": null,
  "is_ok": true
}
モバイルゲートウェイのDNSサーバを変更¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/dnsresolver \
  -d '{
  "sim_group": {
    "dns_1": "1.1.1.1",
    "dns_2": "1.0.0.1"
  }
}'
レスポンス例
{
  "is_ok": true
}
モバイルゲートウェイのSIMルートを取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/simroutes
レスポンス例
{
  "is_ok": true,
  "sim_routes": [
    {
      "iccid": "898104xxxxxxxxxxxxx",
      "prefix": "192.168.1.0/24",
      "resource_id": "xxxxxxxxxxxx",
    }
  ]
}
モバイルゲートウェイのSIMルートを更新¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/simroutes \
  -d '{
  "sim_routes": [
    {
      "resource_id": "xxxxxxxxxxxx",
      "prefix": "192.168.1.0/24"
    }
  ]
}'
レスポンス例
{
  "is_ok": true
}
モバイルゲートウェイのトラフィックコントロール設定を取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/traffic_monitoring
レスポンス例
{
  "traffic_monitoring_config": {
    "traffic_quota_in_mb": 512,
    "auto_traffic_shaping": true,
    "bandwidth_limit_in_kbps": 100000,
    "email_config": {
      "enabled": true
    },
    "slack_config": {
      "enabled": true,
      "slack_url": "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX"
    }
  }
}
モバイルゲートウェイのトラフィックコントロール設定を更新¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X PUT \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/traffic_monitoring \
  -d '{
  "traffic_monitoring_config": {
    "traffic_quota_in_mb": 512,
    "auto_traffic_shaping": true,
    "bandwidth_limit_in_kbps": 100000,
    "email_config": {
      "enabled": true
    },
    "slack_config": {
      "enabled": true,
      ""slack_url": "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX""
    }
  }
}'
レスポンス例
{
  "is_ok": true
}
モバイルゲートウェイのトラフィックコントロール設定を削除¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X DELETE \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/traffic_monitoring
レスポンス例
{
  "is_ok": true
}
モバイルゲートウェイのトラフィック状況を取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/traffic_status
レスポンス例
{
  "is_ok": true,
  "traffic_status": {
    "uplink_bytes": "1835817",
    "downlink_bytes": "23666630",
    "traffic_shaping": false
  }
}
モバイルゲートウェイに登録されているSIM一覧¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/sims \
  --get \
  --data-urlencode '{"From":0,"Count":1}'
レスポンス例
{
  "sim": [
    {
      "iccid": "898104xxxxxxxxxxxxx",
      "imsi": [
        "xxxxxxxxxxxxxxx"
      ],
      "ip": "192.168.0.11",
      "session_status": "DOWN",
      "imei_lock": false,
      "registered": true,
      "activated": true,
      "resource_id": "xxxxxxxxxxxx",
      "registered_date": "2018-03-19T13:20:13+00:00",
      "activated_date": "2018-03-19T13:20:14+00:00",
      "simgroup_id": "xxxxxxxxxxxx",
      "traffic_bytes_of_current_month": {
        "uplink_bytes": 2404544,
        "downlink_bytes": 7963025
      },
      "connected_imei": "xxxxxxxxxxxxxxx"
    }
  ],
  "is_ok": true,
  "Total": 1,
  "From": 0,
  "Count": 1
}
モバイルゲートウェイにSIMを登録¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X POST \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/sims \
  -d '{
  "sim": {
    "resource_id": "xxxxxxxxxxxx"
  }
}'
レスポンス例
{
  "is_ok": true
}
エラーとなる設定例① (さくらのクラウドへ未登録のSIMをモバイルゲートウェイに追加)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X POST \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/sims \
  -d '{
  "sim": {
    "resource_id": "xxxxxxxxxxxx"
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "404 Not Found",
  "error_code": "not_found",
  "error_msg": "対象が見つかりません。対象は利用できない状態か、IDまたはパスに誤りがあります。"
}
エラーとなる設定例② (モバイルゲートウェイに追加済のSIMを登録しようとする)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X POST \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/sims \
  -d '{
  "sim": {
    "resource_id": "xxxxxxxxxxxx"
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "409 Conflict",
  "error_code": "conflict",
  "error_msg": "要求された操作を行えません。現在の対象の状態では、この操作を受け付けできません。\n対象はモバイルゲートウェイに所属済です。"
}
エラーとなる設定例③ (存在しないモバイルゲートウェイを指定する)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X POST \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/sims \
  -d '{
  "sim": {
    "resource_id": "xxxxxxxxxxxx"
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "404 Not Found",
  "error_code": "not_found",
  "error_msg": "不適切な要求です。パラメータの指定誤り、入力規則違反です。入力内容をご確認ください。"
}
エラーとなる設定例④ (モバイルゲートウェイのSIM追加枚数の上限を超えている)¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X POST \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/sims \
  -d '{
  "sim": {
    "resource_id": "xxxxxxxxxxxx"
  }
}'
レスポンス例
{
  "is_fatal": true,
  "serial": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "409 Conflict",
  "error_code": "conflict",
  "error_msg": "要求された操作を行えません。現在の対象の状態では、この操作を受け付けできません。"
}
モバイルゲートウェイからSIMを削除¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X DELETE \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/sims/$SIM_ID
レスポンス例
{
  "is_ok": true
}
モバイルゲートウェイの削除¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  -X DELETE \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID
レスポンス例
{
  "Appliance": {
    "ID": "xxxxxxxxxxxx",
    "Class": "mobilegateway",
    "Name": "example-mgw",
    "Description": "",
    "Plan": {
      "ID": 2
    },
    "Settings": {
      "MobileGateway": {
        "Interfaces": [
          null,
          {
            "IPAddress": [
              "192.168.0.1"
            ],
            "NetworkMaskLen": 24
          }
        ],
        "InternetConnection": {
          "Enabled": "True"
        },
        "StaticRoutes": [
          {
            "Prefix": "172.16.1.0/24",
            "NextHop": "192.168.0.254"
          },
          {
            "Prefix": "172.16.2.0/24",
            "NextHop": "192.168.0.254"
          }
        ],
        "InterDeviceCommunication": {
          "Enabled": "True"
        }
      }
    },
    "SettingsHash": "6dab2e7a0a47bdec844d36db79420b76",
    "Remark": {
      "Servers": [
        []
      ],
      "Switch": {
        "Scope": "shared"
      },
      "Zone": {
        "ID": "30293"
      }
    },
    "Availability": "available",
    "Instance": null,
    "ServiceClass": "cloud/appliance/mobilegateway/1",
    "CreatedAt": "2018-04-04T16:04:14+09:00",
    "Icon": null,
    "Switch": null,
    "Interfaces": [],
    "Tags": []
  },
  "Success": true,
  "is_ok": true
}
モバイルゲートウェイのセッションログの取得¶
curlコマンド例
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
  https://secure.sakura.ad.jp/cloud/zone/$SAKURACLOUD_ZONE/api/cloud/1.1/appliance/$APPLIANCE_ID/mobilegateway/sessionlog \
  --get \
  --data-urlencode '{"Count":2}'
レスポンス例
{
  "is_ok": true,
  "logs": [
    {
      "date": "2018-04-04T15:03:11+00:00",
      "session_status": "Created",
      "resource_id": "113000043845",
      "imei": "xxxxxxxxxxxxxxx",
      "imsi": "xxxxxxxxxxxxxxx"
    },
    {
      "date": "2018-04-04T15:03:09+00:00",
      "session_status": "Deleted",
      "resource_id": "xxxxxxxxxxxx",
      "imsi": "xxxxxxxxxxxxxxx"
    }
  ],
  "Count": 2
}
