in pygenie/client.py [0:0]
def get_commands_for_cluster(self, cluster_id, status=None):
"""
Get commands for a cluster
Args:
cluster_id (str): the cluster id
status (optional[str]): filter by this status
Returns:
dict: a dictionary of commands
Examples:
>>> get_commands_for_cluster('cluster1')
>>> ['cmd1', 'cmd2', 'cmd3']
>>> get_commands_for_cluster('cluster1', 'UP')
>>> ['cmd2']
"""
path = self.path_cluster + '/' + cluster_id + '/commands'
status = status or None
if status:
status = {'status': status}
resp = self.call(path, none_on_404=True, params=status) or {}
# Return dotdict for any commands
if resp.get('response'):
return [DotDict(i) for i in resp['response']]
else:
return []