graviteeio_cli/commands/apim/apis/health.py
def health(obj, output, query, api_id):
    """API health: return the lastest availability: minute, hour, day, week, month"""
    api_client: ApiClient = obj['api_client']

    health_values = None
    # health = api_client.health(api_id, time_frame_seconds = parse(time_frame))
    health = api_client.health(api_id)
    if 'global' in health:
        health_values = health['global']
    else:
        click.echo("No health data")
        return

    to_return = []
    for key, value in health_values.items():
        to_return.append(
            {
                "time": key,
                "percent": round(value, 2)
            }
        )

    try:
        health_filtered = jmespath.search(query, to_return, jmespath.Options(custom_functions=GioFunctions()))

        header = None
        if len(health_filtered) > 0 and type(health_filtered[0]) is dict:
            header = health_filtered[0].keys()

        outputFormat = OutputFormatType.value_of(output)
        outputFormat.echo(health_filtered, header=header)
    except exceptions.JMESPathError as jmespatherr:
        logging.exception("HEALTH JMESPathError exception")
        raise GraviteeioError(str(jmespatherr))
    except Exception:
        logging.exception("HEALTH Exception")
        raise GraviteeioError("to print {} with the format {}.".format(health_filtered, format))
API health: return the lastest availability: minute, hour, day, week, month
API health: return the lastest availability: minute, hour, day, week, month
API health : return the lastest availability : minute hour day week month
def health(obj, output, query, api_id):
    api_client: ApiClient = obj['api_client']
    health_values = None
    health = api_client.health(api_id)
    if 'global' in health:
        health_values = health['global']
    else:
        click.echo("No health data")
        return
    to_return = []
    for key, value in health_values.items():
        to_return.append(
            {
                "time": key,
                "percent": round(value, 2)
            }
        )
    try:
        health_filtered = jmespath.search(query, to_return, jmespath.Options(custom_functions=GioFunctions()))
        header = None
        if len(health_filtered) > 0 and type(health_filtered[0]) is dict:
            header = health_filtered[0].keys()
        outputFormat = OutputFormatType.value_of(output)
        outputFormat.echo(health_filtered, header=header)
    except exceptions.JMESPathError as jmespatherr:
        logging.exception("HEALTH JMESPathError exception")
        raise GraviteeioError(str(jmespatherr))
    except Exception:
        logging.exception("HEALTH Exception")
        raise GraviteeioError("to print {} with the format {}.".format(health_filtered, format))
def health ( obj , output , query , api_id ) : api_client : ApiClient = obj [ 'api_client' ] health_values = None health = api_client . health ( api_id ) if 'global' in health : health_values = health [ 'global' ] else : click . echo ( "No health data" ) return to_return = [ ] for key , value in health_values . items ( ) : to_return . append ( { "time" : key , "percent" : round ( value , 2 ) } ) try : health_filtered = jmespath . search ( query , to_return , jmespath . Options ( custom_functions = GioFunctions ( ) ) ) header = None if len ( health_filtered ) > 0 and type ( health_filtered [ 0 ] ) is dict : header = health_filtered [ 0 ] . keys ( ) outputFormat = OutputFormatType . value_of ( output ) outputFormat . echo ( health_filtered , header = header ) except exceptions . JMESPathError as jmespatherr : logging . exception ( "HEALTH JMESPathError exception" ) raise GraviteeioError ( str ( jmespatherr ) ) except Exception : logging . exception ( "HEALTH Exception" ) raise GraviteeioError ( "to print {} with the format {}." . format ( health_filtered , format ) )
API health: return the lastest availability: minute, hour, day, week, month
API health : return the lastest availability : minute hour day week month
"""API health: return the lastest availability: minute, hour, day, week, month""" # health = api_client.health(api_id, time_frame_seconds = parse(time_frame))
obj
output
query
api_id