mirror of https://git.48k.eu/ogcli/
Add ogcli list client command
This requests GET /client/properties by calling something like: ogcli list client --id=6 It is important to notice that 'id' must be a "computer" type scope id.master
parent
f4e1bb767b
commit
513308fe81
|
@ -48,13 +48,16 @@ class OgCLI():
|
|||
self.rest = OgREST(cfg['ip'], cfg['port'], cfg['api_token'])
|
||||
|
||||
def list(self, args):
|
||||
choices = ['clients', 'scopes', 'modes', 'hardware']
|
||||
choices = ['clients', 'scopes', 'modes', 'hardware',
|
||||
'client']
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('item', choices=choices)
|
||||
parsed_args = parser.parse_args([args[0]])
|
||||
|
||||
if parsed_args.item == 'clients':
|
||||
OgClient.list_clients(self.rest)
|
||||
elif parsed_args.item == 'client':
|
||||
OgClient.get_client_properties(self.rest, args[1:])
|
||||
elif parsed_args.item == 'hardware':
|
||||
OgClient.list_client_hardware(self.rest, args[1:])
|
||||
elif parsed_args.item == 'modes':
|
||||
|
|
|
@ -28,3 +28,17 @@ class OgClient():
|
|||
'type': 'computer'}}
|
||||
r = rest.get('/hardware', payload=payload)
|
||||
print(r.json())
|
||||
|
||||
@staticmethod
|
||||
def get_client_properties(rest, args):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--id',
|
||||
nargs=1,
|
||||
required=True,
|
||||
help='ID of the computer scope')
|
||||
parsed_args = parser.parse_args(args)
|
||||
|
||||
payload = {'scope': {'id': int(parsed_args.id[0]),
|
||||
'type': 'computer'}}
|
||||
r = rest.get('/client/properties', payload=payload)
|
||||
print(r.json())
|
||||
|
|
Loading…
Reference in New Issue