[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:05:26 UTC 2016


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

---
 README.md | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/README.md b/README.md
index e9c8983..5a77a74 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 directly
+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