Skip to content
Browse files

My first pass at a basic API.

  • Loading branch information...
1 parent 4d594f5 commit 03af4cb296beb4be7bb591d2ae60c958538a1c76 @kzalewski kzalewski committed
Showing with 24 additions and 0 deletions.
  1. +24 −0 www/api/index.php
View
24 www/api/index.php
@@ -0,0 +1,24 @@
+<?php
+
+define('API_PREFIX', '/api/1.0/');
+define('API_PREFIX_LEN', strlen(API_PREFIX));
+define('SCRIPT_DIR', dirname(__FILE__).'/../../scripts');
+
+$reqUri = $_SERVER['REQUEST_URI'];
+
+// Only API 1.0 is current supported.
+if (strncmp($reqUri, API_PREFIX, API_PREFIX_LEN) !== 0) {
+ die("API call is not in correct format\n");
+}
+
+$apiCmd = substr($reqUri, API_PREFIX_LEN);
+
+switch ($apiCmd) {
+ case "getInstances":
+ system(SCRIPT_DIR.'/iterateInstances.sh -q --live-fast');
+ break;
+ default:
+ die("[$apiCmd]: Invalid API command\n");
+}
+
+?>

0 comments on commit 03af4cb

Please sign in to comment.
Something went wrong with that request. Please try again.