Example of API usage¶
[Update: October 4, 2018]
This is an example of using API related to Secure Mobile Connect.
Important
For general information such as methods of using SAKURA Cloud API, please refer to API document.
For information on basic appliance operation, please refer to Appliance-related API.
SIM related¶
Hint
For the API of zone shared resources such as SIM, we recommend using the Ishikari Zone No. 1 (isla) endpoint.
Acquire SIM list¶
Example of curl command
curl -u "$SAKURACLOUD_ACCESS_TOKEN:$SAKURACLOUD_ACCESS_TOKEN_SECRET" \
https://secure.sakura.ad.jp/cloud/zone/is1a/api/cloud/1.1/commonserviceitem
Example response
{
"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
}
Acquire SIM list (with SIM details)¶
Using [Include] makes it possible to include detailed information for SIM.
Example of curl command
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"}}'
Example response
{
"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
}
Acquire SIM information¶
Example of curl command
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
Example response
{
"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
}
Acquire SIM status¶
Example of curl command
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
Example response
{
"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
}
Create SIM¶
Example of curl command
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"
}
}
}'
Example response
{
"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
}
Activate SIM¶
Example of curl command
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
Example response
{
"is_ok": true
}
Deactivate SIM¶
Example of curl command
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
Example response
{
"is_ok": true
}
Reconnect SIM¶
Example of curl command
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
Example response
{
"is_ok": true
}
Delete SIM¶
Example of curl command
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
Example response
{
"is_ok": true
}
Update SIM carrier settings¶
Example of curl command
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
}
]
}'
Example response
{
"is_ok": true
}
Acquire SIM carrier settings¶
Example of curl command
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
Example response
{
"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
}
]
}
Set the IP address for SIM¶
Attention
It is only possible to set an IP address for SIM that has already been added to the mobile gateway.
Example of curl command
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"
}
}'
Example response
{
"is_ok": true
}
Delete the IP address for SIM¶
Example of curl command
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
Example response
{
"is_ok": true
}
Set the IMEI for SIM¶
Example of curl command
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"
}
}'
Example response
{
"is_ok": true
}
Delete the IMEI for SIM¶
Example of curl command
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
Example response
{
"is_ok": true
}
Acquire the SIM session log¶
Example of curl command
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}'
Example response
{
"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
}
Acquire SIM metric¶
Example of curl command
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"}'
Example response
{
"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
}
}
}
Mobile gateway related¶
Mobile gateway list¶
Example of curl command
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"}}'
Example response
{
"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
}
Acquire mobile gateway information¶
Example of curl command
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
Example response
{
"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
}
Create a mobile gateway¶
Example of curl command
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"
}
}
}
}'
Example response
{
"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
}
Change settings for a mobile gateway¶
Attention
It is necessary to update settings after changing settings.
Example of curl command
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"
}
}
}
}
}'
Example response
{
"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
}
Update the mobile gateway settings¶
Example of curl command
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
Example response
{
"Success": true,
"ReturnCode": 0,
"ResponseHeaders": {
"Status": "Ok",
"Cause": null
},
"Out": null,
"is_ok": true
}
Change the DNS server for a mobile gateway¶
Example of curl command
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"
}
}'
Example response
{
"is_ok": true
}
Acquire the SIM route for a mobile gateway¶
Example of curl command
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
Example response
{
"is_ok": true,
"sim_routes": [
{
"iccid": "898104xxxxxxxxxxxxx",
"prefix": "192.168.1.0/24",
"resource_id": "xxxxxxxxxxxx",
}
]
}
Update the SIM route for a mobile gateway¶
Example of curl command
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"
}
]
}'
Example response
{
"is_ok": true
}
Acquire traffic control settings for a mobile gateway¶
Example of curl command
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
Example response
{
"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"
}
}
}
Update traffic control settings for a mobile gateway¶
Example of curl command
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""
}
}
}'
Example response
{
"is_ok": true
}
Delete traffic control settings for a mobile gateway¶
Example of curl command
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
Example response
{
"is_ok": true
}
Acquire the traffic status for a mobile gateway¶
Example of curl command
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
Example response
{
"is_ok": true,
"traffic_status": {
"uplink_bytes": "1835817",
"downlink_bytes": "23666630",
"traffic_shaping": false
}
}
SIM list registered to a mobile gateway¶
Example of curl command
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}'
Example response
{
"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
}
Register SIM to a mobile gateway¶
Example of curl command
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"
}
}'
Example response
{
"is_ok": true
}
Delete SIM from a mobile gateway¶
Example of curl command
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
Example response
{
"is_ok": true
}
Delete a mobile gateway¶
Example of curl command
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
Example response
{
"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
}
Acquire the session log for a mobile gateway¶
Example of curl command
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}'
Example response
{
"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
}