[lxc-devel] [lxd/master] Add basic REST API usage example to README.md

monokal on Github lxc-bot at linuxcontainers.org
Fri Apr 22 20:53:07 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 347 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160422/cd75d19e/attachment.bin>
-------------- next part --------------
From 6ad453c9c38c140e5dc9fffe36ec83fe5ef13742 Mon Sep 17 00:00:00 2001
From: Daniel Middleton <monokal at users.noreply.github.com>
Date: Fri, 22 Apr 2016 21:52:35 +0100
Subject: [PATCH] Add basic REST API usage example to README.md

Signed-off-by: Daniel Middleton <d at monokal.io>
---
 README.md | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/README.md b/README.md
index e9c8983..6e4bfda 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,39 @@ shell you're going to interact with lxd from.
 After you've got LXD installed and a session with the right permissions, you
 can take your [first steps](#first-steps).
 
+## Using the REST API
+Here's a simple example of REST API usage via cURL:
+```bash
+curl -k -L -I \
+    --cert ${LXD_API_CRT} \
+    --key ${LXD_API_KEY} \
+    -H "Content-Type: application/json" \
+    -X POST \
+    -d @hello-ubuntu.json \
+    "${LXD_API_URL}/containers"
+```
+where `hello-ubuntu.json` could contain:
+```json
+{
+    "name":"some-ubuntu",
+    "architecture":"x86_64",
+    "profiles":[
+        "default"
+    ],
+    "ephemeral":true,
+    "config":{
+        "limits.cpu":"2"
+    },
+    "source": {
+        "type":"image",
+        "mode":"pull",
+        "protocol":"simplestreams",
+        "server":"https://cloud-images.ubuntu.com/releases",
+        "alias":"14.04"
+    }
+}
+```
+
 ## Building from source
 
 We recommend having the latest versions of liblxc (>= 1.1 required) and CRIU


More information about the lxc-devel mailing list