Difference between revisions of "Category:DigitalOcean"

From Christoph's Personal Wiki
Jump to: navigation, search
Line 7: Line 7:
 
===Environment variables===
 
===Environment variables===
  
  $ API_URL="https://api.digitalocean.com/v2"
+
  $ API_URL="<nowiki>https://api.digitalocean.com/v2</nowiki>"
 
  $ TOKEN=<YOUR_API_TOKEN>
 
  $ TOKEN=<YOUR_API_TOKEN>
  
Line 39: Line 39:
  
 
<pre>
 
<pre>
> POST /v2/droplets HTTP/1.1
 
> User-Agent: curl/7.35.0
 
> Host: api.digitalocean.com
 
> Accept: */*
 
> Authorization: Bearer <TOKEN>
 
> Content-Type: application/json
 
 
# RESPONSE BODY:
 
# RESPONSE BODY:
 
{
 
{
Line 88: Line 82:
  
 
  $ curl -XGET "${API_URL}/droplets" \
 
  $ curl -XGET "${API_URL}/droplets" \
         -H "Content-Type: application/json" \
+
         -H "Authorization: Bearer ${TOKEN}" \
         -H "Authorization: Bearer ${TOKEN}" | python -mjson.tool
+
         -H "Content-Type: application/json" | python -mjson.tool
  
 
==External links==
 
==External links==

Revision as of 21:13, 5 May 2015

This category will be all about using DigitalOcean's various Cloud products and services.

DigitalOcean API

Note: This category and associated articles will only cover version 2 (v2) of the DigitalOcean API.

Environment variables

$ API_URL="https://api.digitalocean.com/v2"
$ TOKEN=<YOUR_API_TOKEN>

I will be using the above environment variables for the remainder of this article.

Regions

$ curl "${API_URL}/regions" \
       -H "Authorization: Bearer ${TOKEN}" \
       -H "Content-Type: application/json" | python -mjson.tool
  • ams1 ("Amsterdam 1")
  • ams2 ("Amsterdam 2")
  • ams3 ("Amsterdam 3")
  • fra1 ("Frankfurt 1")
  • lon1 ("London 1")
  • nyc1 ("New York 1")
  • nyc2 ("New York 2")
  • nyc3 ("New York 3")
  • sfo1 ("San Francisco 1")
  • sgp1 ("Singapore 1")

Droplets

  • Create a Droplet:
$ curl -vXPOST "${API_URL}/droplets" \
   -d'{"name":"my-test-droplet","region":"nyc3","size":"512mb","image":"ubuntu-14-04-x64"}' \
   -H "Authorization: Bearer ${TOKEN}" \
   -H "Content-Type: application/json"
# RESPONSE BODY:
{
    "droplet": {
        "backup_ids": [],
        "created_at": "2015-05-05T20:26:24Z",
        "disk": 20,
        "features": [
            "virtio"
        ],
        "id": 1234567,
        "image": {},
        "kernel": {
            "id": 2924,
            "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-43-generic",
            "version": "3.13.0-43-generic"
        },
        "locked": true,
        "memory": 512,
        "name": "my-test-droplet",
        "networks": {},
        "next_backup_window": null,
        "region": {},
        "size": {},
        "size_slug": "512mb",
        "snapshot_ids": [],
        "status": "new",
        "vcpus": 1
    },
    "links": {
        "actions": [
            {
                "href": "https://api.digitalocean.com/v2/actions/87654321",
                "id": 87654321,
                "rel": "create"
            }
        ]
    }
}
  • List Droplets on your account:
$ curl -XGET "${API_URL}/droplets" \
       -H "Authorization: Bearer ${TOKEN}" \
       -H "Content-Type: application/json" | python -mjson.tool

External links

This category currently contains no pages or media.