aboutsummaryrefslogtreecommitdiffstats
path: root/gsxcl2
diff options
context:
space:
mode:
Diffstat (limited to 'gsxcl2')
-rwxr-xr-xgsxcl255
1 files changed, 55 insertions, 0 deletions
diff --git a/gsxcl2 b/gsxcl2
new file mode 100755
index 0000000..83f1b41
--- /dev/null
+++ b/gsxcl2
@@ -0,0 +1,55 @@
+#! /usr/bin/env php
+<?php
+
+if (TRUE) {
+ error_reporting( E_ALL|E_STRICT );
+}
+
+require 'gsxlib.php';
+
+$opts = getopt( 's:u:p:r:e:m:q:f:d:' );
+
+$region = (isset($opts['r'])) ? $opts['r'] : 'emea';
+$format = (isset($opts['f'])) ? $opts['f'] : 'print_r';
+$environment = (isset($opts['e'])) ? $opts['e'] : null;
+
+$gsx = GsxLib::getInstance($opts['s'], $opts['u'], $opts['p'], $environment, $region);
+
+$api = $argv[7];
+$valid = false;
+
+$client = $gsx->getClient();
+$functions = $client->__getFunctions();
+
+if($argv[8] == 'list') {
+ print_r($functions);
+ exit();
+}
+
+foreach($functions as $f) {
+ if(strstr($f, $api)) {
+ $valid = true;
+ }
+}
+
+if(!$valid) {
+ exit(sprintf('Function "%s" is invalid', $api));
+}
+
+$params = json_decode($argv[8], TRUE);
+
+if($params === NULL) {
+ exit('Invalid params!');
+}
+
+$session = array('userSession' => array('userSessionId' => $gsx->getSessionId()));
+$req = "{$api}Request";
+
+if($api == 'CompTIACodes') {
+ $req = 'ComptiaCodeLookupRequest';
+}
+
+$request = array($req => array_merge($params, $session));
+$result = $client->$api($request);
+
+print_r($result);