def handle(options, args): """ `YOMP GET` handler. """ (endpoint, apikey) = YOMPcli.getCommonArgs(parser, args) server = "%(scheme)s://%(netloc)s" % urlparse(endpoint)._asdict() YOMP = YOMPSession(server=server, apikey=apikey) response = YOMP.get(endpoint) if isinstance(response, Response): if hasattr(options, "useYaml"): if options.useYaml: print yaml.safe_dump(yaml.load(response.text), default_flow_style=False) else: print response.text sys.exit(not int(bool(response)))
def handle(options, args): """ `YOMP GET` handler. """ (endpoint, apikey) = YOMPcli.getCommonArgs(parser, args) server = "%(scheme)s://%(netloc)s" % urlparse(endpoint)._asdict() YOMP = YOMPSession(server=server, apikey=apikey) response = YOMP.get(endpoint) if isinstance(response, Response): if hasattr(options, "useYaml"): if options.useYaml: print yaml.safe_dump(yaml.load(response.text), default_flow_style=False) else: print response.text sys.exit(not int(bool(response)))
"metricSpec": { "uid": uid, "resource": "My Resource Name", "unit": "Files Open", }, "modelParams": { "min": 0, "max": 20000, } }) model = models[0] assert model["uid"] == uid assert model["name"] == METRIC_NAME # Get model status for _ in xrange(30): modelResponse = YOMP.get(YOMP.server + "/_models/" + uid, auth=YOMP.auth) models = modelResponse.json() model = models[0] if model["status"] == 1: break time.sleep(10) else: raise Exception('Model did not transition to "ready" status in a ' "reasonable amount of time.") print ('Your model is ready and YOMP is actively monitoring the "%s"' " custom metric. You can monitor the progress in the YOMP Android" " Client." % METRIC_NAME)