API使用例

[更新: 2018年10月4日]

「セキュアモバイルコネクト」関連のAPIの使用例です。

重要

さくらのクラウドAPIの利用方法など、一般的な情報については APIドキュメント を参照ください。
また、基本的なアプライアンスの操作については アプライアンス関連API をご参照ください。

SIM関連

ヒント

SIMのようなゾーン共通リソースのAPIは石狩第1ゾーン(is1a)のエンドポイントの利用を推奨します。

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情報の取得

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
}

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の無効化

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
    }
  ]
}'

レスポンス例

{
  "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/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
}

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/applience \
  --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": 1
      },
      "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/applience/$APPLIANCE_ID

レスポンス例

{
  "Appliance": {
    "ID": "xxxxxxxxxxxx",
    "Class": "mobilegateway",
    "Name": "example-mgw",
    "Description": "",
    "Plan": {
      "ID": 1
    },
    "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": 1
    },
    "Remark": {
      "Servers": [
        {}
      ],
      "Switch": {
        "Scope": "shared"
      }
    }
  }
}'

レスポンス例

{
  "Appliance": {
    "ID": "xxxxxxxxxxxx",
    "Class": "mobilegateway",
    "Name": "example-mgw",
    "Description": "",
    "Plan": {
      "ID": 1
    },
    "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/applience/$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": 1
    },
    "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/applience/$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/applience/$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/applience/$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/applience/$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/applience/$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/applience/$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/applience/$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/applience/$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/applience/$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/applience/$APPLIANCE_ID/mobilegateway/sims \
  -d '{
  "sim": {
    "resource_id": "xxxxxxxxxxxx"
  }
}'

レスポンス例

{
  "is_ok": true
}

モバイルゲートウェイから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/applience/$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/applience/$APPLIANCE_ID

レスポンス例

{
  "Appliance": {
    "ID": "xxxxxxxxxxxx",
    "Class": "mobilegateway",
    "Name": "example-mgw",
    "Description": "",
    "Plan": {
      "ID": 1
    },
    "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/applience/$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
}