flowclient.async_client¶
connect_async¶
connect_async(*, url: str, token: str, api_version: int = 0, ssl_certificate: Union[str, bool] = True) -> flowclient.async_connection.ASyncConnection
Connect to a FlowKit API server and return the resulting Connection object.
Parameters¶
-
url:strURL of the API server, e.g. "https://localhost:9090"
-
token:strJSON Web Token for this API server
-
api_version:int, default0Version of the API to connect to
-
ssl_certificate:typing.Union, defaultTrueProvide a path to an ssl certificate to use, True to use default root certificates, or False to disable ssl verification.
Returns¶
flowclient.async_connection.ASyncConnection
get_available_dates¶
get_available_dates(*, connection: flowclient.async_connection.ASyncConnection, event_types: Optional[List[str]] = None) -> dict
Get available dates for different event types from the database.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
event_types:typing.Optional, defaultNoneThe event types for which to return available dates (for example: ["calls", "sms"]). If None, return available dates for all available event types.
Returns¶
-
dictAvailable dates in the format {event_type: [list of dates]}
get_available_qa_checks¶
get_available_qa_checks(*, connection: flowclient.async_connection.ASyncConnection, event_types: Optional[List[str]] = None) -> List[Dict[str, str]]
Get available QA checks for some or all event types.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
event_types:typing.Optional, defaultNoneThe event types for which to return available checks (for example: ["calls", "sms"]). If None, return available checks for all available event types.
Returns¶
-
typing.ListAvailable checks in the format {"cdr_type":
, "type_of_query_or_check": }
get_available_qa_checks_df¶
get_available_qa_checks_df(*, connection: flowclient.async_connection.ASyncConnection, event_types: Optional[List[str]] = None) -> pandas.core.frame.DataFrame
Get available QA checks for some or all event types as a dataframe.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
event_types:typing.Optional, defaultNoneThe event types for which to return available checks (for example: ["calls", "sms"]). If None, return available checks for all available event types.
Returns¶
-
pandas.core.frame.DataFrameAvailable checks as a dataframe
get_geography¶
get_geography(*, connection: flowclient.async_connection.ASyncConnection, aggregation_unit: str) -> dict
Get geography data from the database.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
aggregation_unit:straggregation unit, e.g. 'admin3'
Returns¶
-
dictgeography data as a GeoJSON FeatureCollection
get_geojson_result¶
get_geojson_result(*, connection: flowclient.async_connection.ASyncConnection, query_spec: dict, disable_progress: Optional[bool] = None) -> dict
Run and retrieve a query of a specified kind with parameters.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
query_spec:dictA query specification to run, e.g.
{'kind':'daily_location', 'params':{'date':'2016-01-01'}} -
disable_progress:typing.Optional, defaultNoneSet to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
dictGeojson
get_geojson_result_by_query_id¶
get_geojson_result_by_query_id(*, connection: flowclient.async_connection.ASyncConnection, query_id: str, poll_interval: int = 1, disable_progress: Optional[bool] = None) -> dict
Get a query by id, and return it as a geojson dict
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
query_id:strIdentifier of the query to retrieve
-
poll_interval:int, default1Number of seconds to wait between checks for the query being ready
-
disable_progress:typing.Optional, defaultNoneSet to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
dictgeojson
get_json_dataframe¶
get_json_dataframe(*, connection: flowclient.async_connection.ASyncConnection, location: str) -> pandas.core.frame.DataFrame
Get a dataframe from a json source.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
location:strAPI enpoint to retrieve json from
Returns¶
-
pandas.core.frame.DataFrameDataframe containing the result
get_qa_check_outcome¶
get_qa_check_outcome(*, connection: flowclient.async_connection.ASyncConnection, event_type: str, check_type: str, event_date: Union[datetime.date, str]) -> str
Get the outcome of a single QA check on a specified date and event type.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
event_type:strThe event type for which to return the outcome.
-
check_type:strThe type of check to get the outcome for.
-
event_date:typing.UnionThe event date to get the QA outcome for.
Returns¶
-
strThe result of the check as a string value
get_qa_check_outcomes¶
get_qa_check_outcomes(*, connection: flowclient.async_connection.ASyncConnection, event_type: str, check_type: str, start_date: Union[datetime.date, str], end_date: Union[datetime.date, str]) -> List[Dict[str, str]]
Get the outcome of a single QA check on one event type over a time range.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
event_type:strThe event type for which to return the outcome.
-
check_type:strThe type of check to get the outcome for.
-
start_date:typing.Union -
end_date:str,datetime.dateThe event date to get QA outcomes between (end date inclusive).
Returns¶
-
typing.ListQA check outputs in the format {"cdr_date":
, "type_of_query_or_check": , "outcome": }
get_qa_check_outcomes_df¶
get_qa_check_outcomes_df(*, connection: flowclient.async_connection.ASyncConnection, event_type: str, check_type: str, start_date: Union[datetime.date, str], end_date: Union[datetime.date, str]) -> pandas.core.frame.DataFrame
Get the outcome of a single QA check on one event type over a time range as a dataframe
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
event_type:strThe event type for which to return the outcome.
-
check_type:strThe type of check to get the outcome for.
-
start_date:typing.Union -
end_date:str,datetime.dateThe event date to get QA outcomes between (end date inclusive).
Returns¶
-
pandas.core.frame.DataFrameQA check outputs with columns cdr_date, type_of_query_or_check, and outcome
get_result¶
get_result(*, connection: flowclient.async_connection.ASyncConnection, query_spec: dict, disable_progress: Optional[bool] = None) -> pandas.core.frame.DataFrame
Run and retrieve a query of a specified kind with parameters.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
query_spec:dictA query specification to run, e.g.
{'kind':'daily_location', 'date':'2016-01-01'} -
disable_progress:typing.Optional, defaultNoneSet to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
pandas.core.frame.DataFramePandas dataframe containing the results
get_result_by_query_id¶
get_result_by_query_id(*, connection: flowclient.async_connection.ASyncConnection, query_id: str, poll_interval: int = 1, disable_progress: Optional[bool] = None) -> pandas.core.frame.DataFrame
Get a query by id, and return it as a dataframe
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
query_id:strIdentifier of the query to retrieve
-
poll_interval:int, default1Number of seconds to wait between checks for the query being ready
-
disable_progress:typing.Optional, defaultNoneSet to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
pandas.core.frame.DataFrameDataframe containing the result
get_result_location_from_id_when_ready¶
get_result_location_from_id_when_ready(*, connection: flowclient.async_connection.ASyncConnection, query_id: str, poll_interval: int = 1, disable_progress: Optional[bool] = None) -> str
Return, once ready, the location at which results of a query will be obtainable.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
query_id:strIdentifier of the query to retrieve
-
poll_interval:int, default1Number of seconds to wait between checks for the query being ready
-
disable_progress:typing.Optional, defaultNoneSet to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
strEndpoint to retrieve results from
get_status¶
get_status(*, connection: flowclient.async_connection.ASyncConnection, query_id: str) -> str
Check the status of a query.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
query_id:strIdentifier of the query to retrieve
Returns¶
-
strQuery status
query_is_ready¶
query_is_ready(*, connection: flowclient.async_connection.ASyncConnection, query_id: str) -> Tuple[bool, httpx.Response]
Check if a query id has results available.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
query_id:strIdentifier of the query to retrieve
Returns¶
-
typing.TupleTrue if the query result is available
run_query¶
run_query(*, connection: flowclient.async_connection.ASyncConnection, query_spec: dict) -> str
Run a query of a specified kind with parameters and get the identifier for it.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
query_spec:dictQuery specification to run
Returns¶
-
strIdentifier of the query
wait_for_query_to_be_ready¶
wait_for_query_to_be_ready(*, connection: flowclient.async_connection.ASyncConnection, query_id: str, poll_interval: int = 1, disable_progress: Optional[bool] = None) -> httpx.Response
Wait until a query id has finished running, and if it finished successfully return the reply from flowapi.
Parameters¶
-
connection:flowclient.async_connection.ASyncConnectionAPI connection to use
-
query_id:strIdentifier of the query to retrieve
-
poll_interval:int, default1Number of seconds to wait between checks for the query being ready
-
disable_progress:typing.Optional, defaultNoneSet to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable
Returns¶
-
httpx.ResponseResponse object containing the reply to flowapi