forked from darkninja13/gsxlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gsxcl2
executable file
·55 lines (39 loc) · 1.08 KB
/
gsxcl2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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);