Skip to content

flowclient.client

connect

connect(*, url: str, token: str, api_version: int = 0, ssl_certificate: Union[str, bool] = True) -> flowclient.connection.Connection
Source: flowclient/client.py

Connect to a FlowKit API server and return the resulting Connection object.

Parameters

  • url: str

    URL of the API server, e.g. "https://localhost:9090"

  • token: str

    JSON Web Token for this API server

  • api_version: int, default 0

    Version of the API to connect to

  • ssl_certificate: typing.Union[str, bool], default True

    Provide a path to an ssl certificate to use, True to use default root certificates, or False to disable ssl verification.

Returns

  • flowclient.connection.Connection

get_available_dates

get_available_dates(*, connection: flowclient.connection.Connection, event_types: Union[NoneType, List[str]] = None) -> dict
Source: flowclient/client.py

Get available dates for different event types from the database.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • event_types: typing.Union[NoneType, typing.List[str]], default None

    The event types for which to return available dates (for example: ["calls", "sms"]). If None, return available dates for all available event types.

Returns

  • dict

    Available dates in the format {event_type: [list of dates]}

get_available_qa_checks

get_available_qa_checks(*, connection: flowclient.connection.Connection, event_types: Union[NoneType, List[str]] = None) -> List[Dict[str, str]]
Source: flowclient/client.py

Get available QA checks for some or all event types.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • event_types: typing.Union[NoneType, typing.List[str]], default None

    The event types for which to return available checks (for example: ["calls", "sms"]). If None, return available checks for all available event types.

Returns

  • typing.List[typing.Dict[str, str]]

    Available checks in the format {"cdr_type": , "type_of_query_or_check":}

get_available_qa_checks_df

get_available_qa_checks_df(*, connection: flowclient.connection.Connection, event_types: Union[NoneType, List[str]] = None) -> pandas.core.frame.DataFrame
Source: flowclient/client.py

Get available QA checks for some or all event types as a dataframe.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • event_types: typing.Union[NoneType, typing.List[str]], default None

    The 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.DataFrame

    Available checks as a dataframe

get_geography

get_geography(*, connection: flowclient.connection.Connection, aggregation_unit: str) -> dict
Source: flowclient/client.py

Get geography data from the database.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • aggregation_unit: str

    aggregation unit, e.g. 'admin3'

Returns

  • dict

    geography data as a GeoJSON FeatureCollection

get_geojson_result

get_geojson_result(*, connection: flowclient.connection.Connection, query_spec: dict, disable_progress: Union[bool, NoneType] = None) -> dict
Source: flowclient/client.py

Run and retrieve a query of a specified kind with parameters.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • query_spec: dict

    A query specification to run, e.g. {'kind':'daily_location', 'params':{'date':'2016-01-01'}}

  • disable_progress: typing.Union[bool, NoneType], default None

    Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable

Returns

  • dict

    Geojson

get_geojson_result_by_query_id

get_geojson_result_by_query_id(*, connection: flowclient.connection.Connection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> dict
Source: flowclient/client.py

Get a query by id, and return it as a geojson dict

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • query_id: str

    Identifier of the query to retrieve

  • poll_interval: int, default 1

    Number of seconds to wait between checks for the query being ready

  • disable_progress: typing.Union[bool, NoneType], default None

    Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable

Returns

  • dict

    geojson

get_json_dataframe

get_json_dataframe(*, connection: flowclient.connection.Connection, location: str) -> pandas.core.frame.DataFrame
Source: flowclient/client.py

Get a dataframe from a json source.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • location: str

    API enpoint to retrieve json from

Returns

  • pandas.core.frame.DataFrame

    Dataframe containing the result

get_qa_check_outcome

get_qa_check_outcome(*, connection: flowclient.connection.Connection, event_type: str, check_type: str, event_date: Union[datetime.date, str]) -> str
Source: flowclient/client.py

Get the outcome of a single QA check on a specified date and event type.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • event_type: str

    The event type for which to return the outcome.

  • check_type: str

    The type of check to get the outcome for.

  • event_date: typing.Union[datetime.date, str]

    The event date to get the QA outcome for.

Returns

  • str

    The result of the check as a string value

get_qa_check_outcomes

get_qa_check_outcomes(*, connection: flowclient.connection.Connection, event_type: str, check_type: str, start_date: Union[datetime.date, str], end_date: Union[datetime.date, str]) -> List[Dict[str, str]]
Source: flowclient/client.py

Get the outcome of a single QA check on one event type over a time range.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • event_type: str

    The event type for which to return the outcome.

  • check_type: str

    The type of check to get the outcome for.

  • start_date: typing.Union[datetime.date, str]

  • end_date: str, datetime.date

    The event date to get QA outcomes between (end date inclusive).

Returns

  • typing.List[typing.Dict[str, str]]

    QA 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.connection.Connection, event_type: str, check_type: str, start_date: Union[datetime.date, str], end_date: Union[datetime.date, str]) -> List[Dict[str, str]]
Source: flowclient/client.py

Get the outcome of a single QA check on one event type over a time rangeas a dataframe

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • event_type: str

    The event type for which to return the outcome.

  • check_type: str

    The type of check to get the outcome for.

  • start_date: typing.Union[datetime.date, str]

  • end_date: str, datetime.date

    The event date to get QA outcomes between (end date inclusive).

Returns

  • typing.List[typing.Dict[str, str]]

    QA check outputs with columns cdr_date, type_of_query_or_check, and outcome

get_result

get_result(*, connection: flowclient.connection.Connection, query_spec: dict, disable_progress: Union[bool, NoneType] = None) -> pandas.core.frame.DataFrame
Source: flowclient/client.py

Run and retrieve a query of a specified kind with parameters.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • query_spec: dict

    A query specification to run, e.g. {'kind':'daily_location', 'date':'2016-01-01'}

  • disable_progress: typing.Union[bool, NoneType], default None

    Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable

Returns

  • pandas.core.frame.DataFrame

    Pandas dataframe containing the results

get_result_by_query_id

get_result_by_query_id(*, connection: flowclient.connection.Connection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> pandas.core.frame.DataFrame
Source: flowclient/client.py

Get a query by id, and return it as a dataframe

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • query_id: str

    Identifier of the query to retrieve

  • poll_interval: int, default 1

    Number of seconds to wait between checks for the query being ready

  • disable_progress: typing.Union[bool, NoneType], default None

    Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable

Returns

  • pandas.core.frame.DataFrame

    Dataframe containing the result

get_result_location_from_id_when_ready

get_result_location_from_id_when_ready(*, connection: flowclient.connection.Connection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> str
Source: flowclient/client.py

Return, once ready, the location at which results of a query will be obtainable.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • query_id: str

    Identifier of the query to retrieve

  • poll_interval: int, default 1

    Number of seconds to wait between checks for the query being ready

  • disable_progress: typing.Union[bool, NoneType], default None

    Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable

Returns

  • str

    Endpoint to retrieve results from

get_status

get_status(*, connection: flowclient.connection.Connection, query_id: str) -> str
Source: flowclient/client.py

Check the status of a query.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • query_id: str

    Identifier of the query to retrieve

Returns

  • str

    Query status

query_is_ready

query_is_ready(*, connection: flowclient.connection.Connection, query_id: str) -> Tuple[bool, httpx.Response]
Source: flowclient/client.py

Check if a query id has results available.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • query_id: str

    Identifier of the query to retrieve

Returns

  • typing.Tuple[bool, httpx.Response]

    True if the query result is available

run_query

run_query(*, connection: flowclient.connection.Connection, query_spec: dict) -> str
Source: flowclient/client.py

Run a query of a specified kind with parameters and get the identifier for it.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • query_spec: dict

    Query specification to run

Returns

  • str

    Identifier of the query

wait_for_query_to_be_ready

wait_for_query_to_be_ready(*, connection: flowclient.connection.Connection, query_id: str, poll_interval: int = 1, disable_progress: Union[bool, NoneType] = None) -> httpx.Response
Source: flowclient/client.py

Wait until a query id has finished running, and if it finished successfully return the reply from flowapi.

Parameters

  • connection: flowclient.connection.Connection

    API connection to use

  • query_id: str

    Identifier of the query to retrieve

  • poll_interval: int, default 1

    Number of seconds to wait between checks for the query being ready

  • disable_progress: typing.Union[bool, NoneType], default None

    Set to True to disable progress bar display entirely, None to disable on non-TTY, or False to always enable

Returns

  • httpx.Response

    Response object containing the reply to flowapi