digitalocean api开机和管理机器的探路

VPS技术分享

digitalocean api开机和管理机器的探路

2021-11-23 18:08


                                            




digitalocean api开机代码

  curl -X POST \

  -H "Content-Type: application/json" \

  -H "Authorization: Bearer f89ece12598e3d471ac269352710a96d85848c881d7c62a9adcc4c4e4d90abab" \

  -d '{"name":"example.com","region":"nyc3","size":"s-1vcpu-1gb","image":"ubuntu-21-10-x64"}' \

  "https://api.digitalocean.com/v2/droplets"

  ---------------------------------------------------------------------

digitalocean api开机代码详解:

  curl -X POST \

  -H "Content-Type: application/json" \

  -H "Authorization: Bearer 这里替换你的api密钥" \

  -d '{"name":"这里替换填写你定义的这个机器的名字英文就行","region":"这里替换填写机器的位置代码","size":"这里替换填写你机器的配置代码","image":"这里替换填写你机器的操作系统代码"}' \

  "https://api.digitalocean.com/v2/droplets"

上面命令的意思是开一台操作系统是ubuntu-21-10-x64的位置在纽约的,配置信息是1个cpu内存是1G的机器

  ---------------------------------------------------------------------

以上命令之后如果成功了,那么就会返回下面的信息:

  {"droplet":{"id":274915900,"name":"example.com","memory":1024,"vcpus":1,"disk":25,"locked":false,"status":"new","kernel":null,"created_at":"2021-11-23T08:48:07Z","features":["droplet_agent"],"backup_ids":[],"next_backup_window":null,"snapshot_ids":[],"image":{"id":94389391,"name":"21.10 x64","distribution":"Ubuntu","slug":"ubuntu-21-10-x64","public":true,"regions":["nyc3","nyc1","sfo1","nyc2","ams2","sgp1","lon1","ams3","fra1","tor1","sfo2","blr1","sfo3"],"created_at":"2021-10-25T21:21:51Z","min_disk_size":15,"type":"base","size_gigabytes":0.6,"description":"Ubuntu 21.10 x64","tags":[],"status":"available"},"volume_ids":[],"size":{"slug":"s-1vcpu-1gb","memory":1024,"vcpus":1,"disk":25,"transfer":1.0,"price_monthly":5.0,"price_hourly":0.00744,"regions":["ams3","blr1","fra1","lon1","nyc1","nyc3","sfo3","sgp1","tor1"],"available":true,"description":"Basic"},"size_slug":"s-1vcpu-1gb","networks":{"v4":[],"v6":[]},"region":{"name":"New York 3","slug":"nyc3","features":["backups","ipv6","metadata","install_agent","storage","image_transfer"],"available":true,"sizes":["s-1vcpu-1gb","s-1vcpu-1gb-amd","s-1vcpu-1gb-intel","s-1vcpu-2gb","s-1vcpu-2gb-amd","s-1vcpu-2gb-intel","s-2vcpu-2gb","s-2vcpu-2gb-amd","s-2vcpu-2gb-intel","s-2vcpu-4gb","s-2vcpu-4gb-amd","s-2vcpu-4gb-intel","s-4vcpu-8gb","c-2","c2-2vcpu-4gb","s-4vcpu-8gb-amd","s-4vcpu-8gb-intel","g-2vcpu-8gb","gd-2vcpu-8gb","s-8vcpu-16gb","m-2vcpu-16gb","c-4","c2-4vcpu-8gb","s-8vcpu-16gb-amd","s-8vcpu-16gb-intel","m3-2vcpu-16gb","g-4vcpu-16gb","so-2vcpu-16gb","m6-2vcpu-16gb","gd-4vcpu-16gb","so1_5-2vcpu-16gb","m-4vcpu-32gb","c-8","c2-8vcpu-16gb","m3-4vcpu-32gb","g-8vcpu-32gb","so-4vcpu-32gb","m6-4vcpu-32gb","gd-8vcpu-32gb","so1_5-4vcpu-32gb","m-8vcpu-64gb","c-16","c2-16vcpu-32gb","m3-8vcpu-64gb","g-16vcpu-64gb","so-8vcpu-64gb","m6-8vcpu-64gb","gd-16vcpu-64gb","so1_5-8vcpu-64gb","c-32","c2-32vcpu-64gb","g-32vcpu-128gb","so-16vcpu-128gb","gd-32vcpu-128gb","so1_5-16vcpu-128gb","so-24vcpu-192gb","so1_5-24vcpu-192gb"]},"tags":[]},"links":{"actions":[{"id":1355094236,"rel":"create","href":"https://api.digitalocean.com/v2/actions/1355094236"}]}}

 

digitalocean api密钥长啥样?:f89ece12598e3d471ac269352710a96d85848c881d7c62a9adcc4c4e4d90abab

大概就是上面这串很长很长的字符串这样子。

 

评价:digitalocean api对外暴露的api完全不能满足正常的需求。比如开完机器怎么通过digitalocean api代码获取digitalocean机器的ip和密码?digitalocean api完全就没暴露出来。所以这里暂时不做更多的介绍了。不知道以后会怎样。