如何使用DigitalOcean API获取基本图像ID?

时间:2014-12-05 14:44:34

标签: image deployment digital-ocean

我正在尝试使用api服务在ams1中部署一个标准的Ubuntu 14.04图像。但是,到目前为止,我还无法找到合适的ID。

我已尝试使用

curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582' "https://api.digitalocean.com/v2/images?page=1&per_page=1" 

来自https://developers.digitalocean.com/#list-all-application-images

和类似的通过dopy(https://pypi.python.org/pypi/dopy

它输出所有花哨的装置,如Ubuntu上的MEAN,Ubuntu 14.04上的Dokku等,但不是Ubuntu 14.04的基本发行版。谁知道如何获得这个?

谢谢, 麦克

2 个答案:

答案 0 :(得分:4)

curl -X GET -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer '$TOKEN'' \    
    "https://api.digitalocean.com/v2/images?page=1&per_page=1"

也应该返回基本分布。请注意,结果是分页的。增加per_page参数以在单个查询中查看更多内容。您还可以使用type参数专门过滤“applications”或“distribution”。因此,要仅检索基本图像,请使用:

curl -X GET -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer '$TOKEN'' \
    "https://api.digitalocean.com/v2/images?per_page=100&type=distribution"

此外,您通常希望在启动Droplet时使用图像slug。如果图片有更新,则id会发生变化,但slug保证稳定。

完全披露,其中包括我是Digitalocean的社区经理

答案 1 :(得分:0)

不确定所有帐户的ID是否相同,但我们继续。

https://api.digitalocean.com/images/?client_id=xxx&api_key=xxx

14.04 x32

{"id":6918735,"name":"14.04 x32","slug":"ubuntu-14-04-x32","distribution":"Ubuntu","public":true,"regions":[1,2,3,4,5,6,7,8,9],"region_slugs":["nyc1","ams1","sfo1","nyc2","ams2","sgp1","lon1","nyc3","ams3"]}

14.04 x64

{"id":6918990,"name":"14.04 x64","slug":"ubuntu-14-04-x64","distribution":"Ubuntu","public":true,"regions":[1,2,3,4,5,6,7,8,9],"region_slugs":["nyc1","ams1","sfo1","nyc2","ams2","sgp1","lon1","nyc3","ams3"]}