Difference between revisions of "Category:DigitalOcean"

From Christoph's Personal Wiki
Jump to: navigation, search
(New page: This category will be all about using '''[https://www.digitalocean.com/ DigitalOcean's]''' various Cloud products and services. ==DigitalOcean API v2== [[Category:Technical and Specializ...)
 
Line 1: Line 1:
 
This category will be all about using '''[https://www.digitalocean.com/ DigitalOcean's]''' various Cloud products and services.
 
This category will be all about using '''[https://www.digitalocean.com/ DigitalOcean's]''' various Cloud products and services.
  
==DigitalOcean API v2==
+
==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"
 +
 
 +
<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:
 +
{
 +
    "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"
 +
            }
 +
        ]
 +
    }
 +
}
 +
</pre>
 +
 
 +
* List Droplets on your account:
 +
 
 +
$ curl -XGET "${API_URL}/droplets" \
 +
        -H "Content-Type: application/json" \
 +
        -H "Authorization: Bearer ${TOKEN}" | python -mjson.tool
 +
 
 +
==External links==
 +
* [https://developers.digitalocean.com/documentation/v2/ DigitalOcean API Documentation]
  
 
[[Category:Technical and Specialized Skills]]
 
[[Category:Technical and Specialized Skills]]

Revision as of 21:10, 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"
> 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:
{
    "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 "Content-Type: application/json" \
       -H "Authorization: Bearer ${TOKEN}" | python -mjson.tool

External links

This category currently contains no pages or media.