Query

Environmental Intelligence: Geospatial APIs SDK (ibmpairs): A Python module to wrap the core functionality of the Geospatial APIs component.

Copyright 2019-2024 IBM Software: Sustainability, IBM Corp. All Rights Reserved.

SPDX-License-Identifier: BSD-3-Clause

class query.AOI(client: Client = None, id: int = None, key: str = None, name: str = None, hierarchy: str = None, description: str = None, geojson: Any = None, wkt: Any = None, bbox: Any = None)

A representation of an AOI.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • id (int) – An AOI ID.

  • key (str) – An AOI key.

  • name (str) – An AOI name.

  • hierarchy (str) – An AOI hierarchy.

  • description (str) – An AOI description.

  • geojson (Any) – An AOI geojson geometry.

  • wkt (Any) – An AOI wkt geometry.

  • bbox (Any) – An AOI bbox.

display(columns: List[str] = ['id', 'key', 'name', 'hierarchy', 'description', 'geojson', 'wkt', 'bbox'])

A method to return a pandas.DataFrame object of a get result.

Parameters:

columns (List[str]) – The columns to be returned in the pandas.DataFrame object, defaults to [‘id’, ‘key’, ‘name’, ‘hierarchy’, ‘description’, ‘geojson’, ‘wkt’, ‘bbox’]

Returns:

A pandas.DataFrame of attributes from the object.

Return type:

pandas.DataFrame

from_dict()

Create an AOI object from a dictionary.

Parameters:

aoi_dict (Any) – A dictionary that contains the keys of an AOI.

Return type:

ibmpairs.query.AOI

Raises:

Exception – if not a dictionary.

from_json()

Create an AOI object from json (dictonary or str).

Parameters:

aoi_dict (Any) – A json dictionary that contains the keys of an AOI or a string representation of a json dictionary.

Return type:

ibmpairs.query.AOI

Raises:

Exception – if not a dictionary or a string.

get(id: int = None, geometry_format: str = 'geojson', client: Client = None, verify: bool = True)

A method to get an AOI.

Parameters:
  • id (int) – The AOI ID of the AOI to be gathered.

  • geometry_format (str) – A geometry format, ‘geojson’ or ‘wkt’ (default: geojson)

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Returns:

A populated AOI object.

Return type:

ibmpairs.query.AOI

Raises:

Exception – A ibmpairs.client.Client is not found, an ID is not provided or already held in the object, a server error occurred, the status of the request is not 200.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.AOIs(client: Client = None, aois: List[AOI] = None)

An object to represent a list of AOIs.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • aois (List[ibmpairs.query.AOI]) – A list of AOIs.

Raises:

Exception – An ibmpairs.client.Client is not found.

display(columns: List[str] = ['id', 'key', 'name', 'hierarchy', 'description', 'geojson', 'bbox'], sort_by: str = 'id')

A method to return a pandas.DataFrame object of get results.

Parameters:
  • columns (List[str]) – The columns to be returned in the pandas.DataFrame object, defaults to [‘id’, ‘key’, ‘name’, ‘hierarchy’, ‘description’, ‘geojson’, ‘bbox’]

  • sort_by – The item to sort on, default: id

  • sort_by – str

Returns:

A pandas.DataFrame of attributes from the aois attribute.

Return type:

pandas.DataFrame

from_dict()

Create an AOIs object from a dictionary.

Parameters:

aois_dict (Any) – A dictionary that contains the keys of an AOIs object.

Return type:

ibmpairs.query.AOIs

Raises:

Exception – If not a dictionary.

from_json()

Create a AOIs object from json (dictonary or str).

Parameters:

aois (Any) – A json dictionary that contains the keys of an AOIs or a string representation of a json dictionary.

Return type:

ibmpairs.query.AOIs

Raises:

Exception – If not a dictionary or a string.

get(search_term=None, client: Client = None, verify: bool = True)

A method to get a list of AOIs by search term.

Parameters:
  • search_term (str) – A search on name for the gathered AOIs; by default None (if None, all AOIs).

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Returns:

A populated AOIs object.

Return type:

ibmpairs.query.AOIs

Raises:

Exception – A ibmpairs.client.Client is not found, a server error occurred, the status of the request is not 200.

search(search_term: str, client: Client = None, verify: bool = True)

A method to search all AOI fields.

Parameters:
  • search_term (str) – A term to search on id, key, name, hierarchy and description for the gathered AOIs.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Returns:

A pandas.DataFrame of AOIs that match the search term.

Return type:

pandas.DataFrame

Raises:

Exception – A ibmpairs.client.Client is not found, a server error occurred, the status of the request is not 200.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Aggregation(aoi: List[str] = None)

A representation of a Query Aggregation.

Parameters:

aoi (List[str]) – A definition of areas of interest, part of a query.

from_dict()

Create an Aggregation object from a dictionary.

Parameters:

aggregation_dict (Any) – A dictionary that contains the keys of an Aggregation.

Return type:

ibmpairs.query.Aggregation

Raises:

Exception – if not a dictionary.

from_json()

Create an Aggregation object from json (dictonary or str).

Parameters:

aggregation_dict (Any) – A json dictionary that contains the keys of an Aggregation or a string representation of a json dictionary.

Return type:

ibmpairs.query.Aggregation

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Dimension(name: str = None, value: str = None, operator: str = None, options: List[str] = None)

A representation of a Query Dimension.

Parameters:
  • name (List[str]) – A dimension name.

  • value (str) – A dimension value.

  • operator (str) – A dimension operator.

  • name – A list of options.

from_dict()

Create a Dimension object from a dictionary.

Parameters:

dimension_dict (Any) – A dictionary that contains the keys of a Dimension.

Return type:

ibmpairs.query.Dimension

Raises:

Exception – if not a dictionary.

from_json()

Create a Dimension object from json (dictonary or str).

Parameters:

dimension_dict (Any) – A json dictionary that contains the keys of a Dimension or a string representation of a json dictionary.

Return type:

ibmpairs.query.Dimension

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Filter(value: str = None, operator: str = None, expression: str = None)

A representation of a Query Filter.

Parameters:
  • value (str) – A filter value.

  • operator (str) – A filter operator.

  • expression (str) – An expression, used instead of value, operator.

from_dict()

Create a Filter object from a dictionary.

Parameters:

filter_dict (Any) – A dictionary that contains the keys of a Filter.

Return type:

ibmpairs.query.Filter

Raises:

Exception – if not a dictionary.

from_json()

Create a Filter object from json (dictonary or str).

Parameters:

filter_dict (Any) – A json dictionary that contains the keys of a Filter or a string representation of a json dictionary.

Return type:

ibmpairs.query.Filter

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Group(id: int = None, name: str = None)

A representation of a Group.

Parameters:
  • id (int) – The Group ID.

  • name (str) – The Group name.

from_dict()

Create a Group object from a dictionary.

Parameters:

group_dict (Any) – A dictionary that contains the keys of an Group.

Return type:

ibmpairs.query.Group

Raises:

Exception – if not a dictionary.

from_json()

Create a Group object from json (dictonary or str).

Parameters:

group_dict (Any) – A json dictionary that contains the keys of a Group or a string representation of a json dictionary.

Return type:

ibmpairs.query.Group

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure. :rtype: dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Interval(snapshot: str = None, end: str = None, start: str = None)

A representation of a Query Interval.

Parameters:
  • snapshot (str) – An interval snapshot.

  • end (str) – An end date.

  • start (str) – A start date.

from_dict()

Create an Interval object from a dictionary.

Parameters:

interval_dict (Any) – A dictionary that contains the keys of an Interval.

Return type:

ibmpairs.query.Interval

Raises:

Exception – if not a dictionary.

from_json()

Create an Interval object from json (dictonary or str).

Parameters:

interval_dict (Any) – A json dictionary that contains the keys of an Interval or a string representation of a json dictionary.

Return type:

ibmpairs.query.Interval

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure. :rtype: dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.LatestQueries(client: Client = None, latest_queries: List[Query] = None)

A representation of the Latest Queries made by a user.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • latest_queries (List[ibmpairs.query.Query]) – The latest queries made by a user.

from_dict()

Create an LatestQueries object from a dictionary.

Parameters:

latest_queries_dict (Any) – A dictionary that contains the keys of an LatestQueries.

Return type:

ibmpairs.query.LatestQueries

Raises:

Exception – If not a dictionary.

from_json()

Create a LatestQueries object from json (dictonary or str).

Parameters:

latest_queries_dict (Any) – A json dictionary that contains the keys of a LatestQueries or a string representation of a json dictionary.

Return type:

ibmpairs.query.LatestQueries

Raises:

Exception – If not a dictionary or a string.

get(client: Client = None, favorite_flag: bool = False, number_of_queries: int = 10, verify: bool = True)

A method to get a list of latest queries.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • favorite_flag (bool) – Whether only favorites should be searched.

  • number_of_queries (int) – Number of latest queries to gather.

  • verify (bool) – SSL verification

Raises:

Exception – A ibmpairs.client.Client is not found, the status of the request is not 200, if queries could not be retrieved.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Layer(id: str = None, type: str = None, temporal: Temporal = None, alias: str = None, filter_only: bool = None, aggregation: str = None, filter: Filter = None, dimensions: List[Dimension] = None, expression: str = None, output: bool = None, datalayer: str = None, properties: dict = None)

A representation of a Query Layer.

Parameters:
  • id (str) – A layer id.

  • type (str) – A layer type.

  • temporal (ibmpairs.query.Temporal) – A temporal definition of intervals.

  • alias (str) – An alias name.

  • filter_only (bool) – Filter only.

  • aggregation (str) – An aggregation definition.

  • filter (ibmpairs.query.Filter) – A filter definition.

  • dimensions (List[ibmpairs.query.Dimension]) – A list of dimensions.

  • expression (str) – An expression to be applied.

  • output (bool) – Output.

  • datalayer (str) – A data layer name.

  • properties (dict) – A dictionary of properties associated with a layer.

from_dict()

Create a Layer object from a dictionary.

Parameters:

layer_dict (Any) – A dictionary that contains the keys of a Layer.

Return type:

ibmpairs.query.Layer

Raises:

Exception – if not a dictionary.

from_json()

Create a Layer object from json (dictonary or str).

Parameters:

layer_dict (Any) – A json dictionary that contains the keys of a Layer or a string representation of a json dictionary.

Return type:

ibmpairs.query.Layer

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_dict_layer_post()

Create a dictionary from the objects structure ready for a POST operation.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

to_json_layer_post()

Create a string representation of a json dictionary from the objects structure ready for a POST operation.

Return type:

string

class query.Notification(type: str = None, host: str = None, queue: str = None)

A representation of a Query Notification.

Parameters:
  • type (str) – A type value.

  • host (str) – A host of the holding GeoServer.

  • queue (str) – A queue name.

from_dict()

Create a Notification object from a dictionary.

Parameters:

notification_dict (Any) – A dictionary that contains the keys of a Notification.

Return type:

ibmpairs.query.Notification

Raises:

Exception – if not a dictionary.

from_json()

Create a Notification object from json (dictonary or str).

Parameters:

notification_dict (Any) – A json dictionary that contains the keys of a Notification or a string representation of a json dictionary.

Return type:

ibmpairs.query.Notification

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Options(name: str = None, value: str = None)

A representation of a Processor Option.

Parameters:
  • name (str) – A name for the option.

  • name – A value for the option.

from_dict()

Create an Options object from a dictionary.

Parameters:

options_dict (Any) – A dictionary that contains the keys of a Options.

Return type:

ibmpairs.query.Options

Raises:

Exception – if not a dictionary.

from_json()

Create an Options object from json (dictonary or str).

Parameters:

options_json (Any) – A json dictionary that contains the keys of an Options or a string representation of a json dictionary.

Return type:

ibmpairs.query.Options

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Polygon(wkt: str = None)

A representation of a Query Polygon.

Parameters:

wkt (str) – A Well Known Text (wkt) string.

from_dict()

Create a Polygon object from a dictionary.

Parameters:

polygon_dict (Any) – A dictionary that contains the keys of a Polygon.

Return type:

ibmpairs.query.Polygon

Raises:

Exception – if not a dictionary.

from_json()

Create a Polygon object from json (dictonary or str).

Parameters:

polygon_dict (Any) – A json dictionary that contains the keys of a Polygon or a string representation of a json dictionary.

Return type:

ibmpairs.query.Polygon

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Processor(order: int = None, type: str = None, options: List[Options] = None)

A representation of a Processor.

Parameters:
  • order (int) – A name for the option.

  • type (str) – A value for the option.

  • options (List[ibmpairs.query.Options]) – A list of processor options.

from_dict()

Create a Processor object from a dictionary.

Parameters:

processor_dict (Any) – A dictionary that contains the keys of a Processor.

Return type:

ibmpairs.query.Processor

Raises:

Exception – if not a dictionary.

from_json()

Create a Processor object from json (dictonary or str).

Parameters:

processor_json (Any) – A json dictionary that contains the keys of a Processor or a string representation of a json dictionary.

Return type:

ibmpairs.query.Processor

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Query(client: Client = None, name: str = None, layers: List[Layer] = None, temporal: Temporal = None, spatial: Spatial = None, output_type: str = None, output_level: int = None, description: str = None, publish: bool = None, notification: Notification = None, upload: Upload = None, batch: str = None, processor: List[Processor] = None, debug: bool = None, id: str = None, submit_response: QueryResponse = None, status_response: QueryJob = None, download_status: str = None, download_folder: str = None, download_file_name: str = None, merge_response: QueryJobLayers = None, merge_status: str = None)

A representation of a PAIRS Query.

Parameters:
  • client (ibmpairs.client.Client) – An instance of an ibmpairs.client.Client.

  • name (str) – A name for the query.

  • layers (List[ibmpairs.query.Layer]) – A list of layers to query.

  • spatial (ibmpairs.query.Spatial) – A spatial definition to query.

  • temporal (ibmpairs.query.Temporal) – A temporal definiton to query.

  • output_type (str) – An output type for the query.

  • output_level (int) – An output level for the query.

  • description (str) – A description for the query.

  • publish (bool) – A publish to GeoServer flag.

  • notification (ibmpairs.query.Notification) – A notification object definition.

  • upload (ibmpairs.query.Upload) – An upload object definition.

  • batch (str) – A batch indicator.

  • processor (List[ibmpairs.query.Processor]) – A list of post processors to apply to a query.

  • debug (bool) – A debug flag.

  • id (str) – A Query id.

  • submit_response (ibmpairs.query.QueryResponse) – A response from the submit phase.

  • status_response (ibmpairs.query.QueryJob) – A response from the status polling phase.

  • download_status (str) – A response from the download phase.

  • download_folder (str) – A folder that downloads should be made to (fixed or relative).

  • download_file_name (str) – A file name for the download.

  • merge_response (ibmpairs.query.QueryJobLayers) – A response from a merged query.

  • merge_status (str) – The status of a merge operation.

Raises:

Exception – if no client is provided or found Globally in the environment.

async async_check_status_and_download(query, client: Client = None, poll: bool = True, status_interval: int = 30, download_folder=None, download_file_name=None, verify: bool = True, online: bool = False)

An asynchronous method to check the status of a Query then download the result.

Parameters:
  • query (ibmpairs.query.Query) – The Query to perform the operations on.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should call back.

  • download_folder (str) – A download folder (fixed or relative).

  • download_file_name (str) – A file name for the download.

  • verify (bool) – SSL verification

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

Raises:

Exception – A ibmpairs.client.Client is not found, query is not present, the Query status failed, the download folder could not be made or identified, the download failed, error making request to server, the status of the request is not 200.

async async_download(query, client: Client = None, status_interval: int = 30, download_folder=None, download_file_name=None, verify: bool = True, online=False)

An asynchronous method to download and unzip a Query result.

Parameters:
  • query (ibmpairs.query.Query) – The Query to check the status of and download.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • status_interval (int) – How often the async run operation should call back.

  • download_folder (str) – A download folder (fixed or relative).

  • download_file_name (str) – A file name for the download.

  • verify (bool) – SSL verification

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

Raises:

Exception – A ibmpairs.client.Client is not found, query is not present, the Query status failed, the download folder could not be made or identified, the download failed, error making request to server, the status of the request is not 200.

async async_status(query, client: Client = None, poll: bool = True, status_interval: int = 30, verify: bool = True)

An asynchronous method to check the status of a Query.

Parameters:
  • query (ibmpairs.query.Query) – The Query to check the status of.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should call back.

  • verify (bool) – SSL verification

Raises:

Exception – A ibmpairs.client.Client is not found, query is not present, the Query failed, error making request to server, the status of the request is not 200.

async async_submit(query, client: Client = None, verify: bool = True, compact_csv: bool = False)

An asynchronous method to submit a Query.

Parameters:
  • query (ibmpairs.query.Query) – The Query to submit.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

Raises:

Exception – A ibmpairs.client.Client is not found, query is not present, error making request to server, the status of the request is not 200.

async async_submit_and_check_status(query, client: Client = None, poll: bool = True, status_interval: int = 30, verify: bool = True, compact_csv: bool = False)

An asynchronous method to submit and check the status of a Query.

Parameters:
  • query (ibmpairs.query.Query) – The Query to perform the operations on.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should check for status (seconds).

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

Raises:

Exception – A ibmpairs.client.Client is not found, query is not present, the Query failed, error making request to server, the status of the request is not 200.

async async_submit_check_status_and_download(query, client: Client = None, poll: bool = True, status_interval: int = 30, download_folder=None, download_file_name=None, verify: bool = True, compact_csv: bool = False, online: bool = False)

An asynchronous method to submit a Query check the status then download the result.

Parameters:
  • query (ibmpairs.query.Query) – The Query to perform the operations on.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should call back.

  • download_folder (str) – A download folder (fixed or relative).

  • download_file_name (str) – A file name for the download.

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

Raises:

Exception – A ibmpairs.client.Client is not found, query is not present, the Query status failed, the download folder could not be made or identified, the download failed, error making request to server, the status of the request is not 200.

check_status_and_download(client: Client = None, id: str = None, poll: bool = True, status_interval: int = 30, download_folder='download', download_file_name=None, verify: bool = True, online: bool = False)

A method to check the status of a Query then download the result.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • id (str) – A Query ID, if None will use id in object.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should call back.

  • download_folder (str) – A download folder (fixed or relative).

  • download_file_name (str) – A file name for the download.

  • verify (bool) – SSL verification

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

Raises:

Exception – A ibmpairs.client.Client is not found, the Query status failed, the download folder could not be made or identified, the download failed, error making request to server, the status of the request is not 200.

download(client: Client = None, id: str = None, status_interval: int = 30, download_folder=None, download_file_name=None, verify: bool = True, online: bool = False)

A method to download and unzip a Query result.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • id (str) – A Query ID, if None will use id in object.

  • status_interval (int) – How often the async run operation should call back.

  • download_folder (str) – A download folder (fixed or relative).

  • download_file_name (str) – A file name for the download.

  • verify (bool) – SSL verification

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

Raises:

Exception – A ibmpairs.client.Client is not found, the Query status failed, the download folder could not be made or identified, the download failed, error making request to server, the status of the request is not 200.

favorite(id: str = None, client: Client = None, favorite_flag=True, verify: bool = True)

A method to favorite a Query.

Parameters:
  • id (str) – The Query ID to be made a favorite.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • favorite_flag (bool) – Favorite flag.

  • verify (bool) – SSL verification

Raises:

Exception – A ibmpairs.client.Client is not found, an ID is not provided or already held in the object, the status of the request is not 200.

from_dict()

Create a Query object from a dictionary.

Parameters:

query_dict (Any) – A dictionary that contains the keys of a Query.

Return type:

ibmpairs.query.Query

Raises:

Exception – if not a dictionary.

from_json()

Create a Query object from json (dictonary or str).

Parameters:

query_dict (Any) – A json dictionary that contains the keys of a Query or a string representation of a json dictionary.

Return type:

ibmpairs.query.Query

Raises:

Exception – if not a dictionary or a string.

is_bulk()

An internal method to determine if query is ‘online’ or bulk.

Returns:

A bulk flag indicator

Return type:

bool

list_files()

A method to list Query result files from the zip.

Returns:

A list of file paths for Query result files.

Return type:

List[str]

merge_query_into_base(other_job_id, base_job_id=None, client=None, verify: bool = True)

A method to merge a Query into a base Query on the server side.

Parameters:
  • other_job_id (str or int) – The ID of the job to be merged.

  • base_job_id (str or int) – The ID of the base job to be merged to.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Raises:

Exception – A ibmpairs.client.Client is not found, other job ID is not provided, base job ID is not provided or already held in the object, the status of the request is not 200.

replace_dates(start_date: datetime, end_date: datetime, name=None)

A method to replace the dates in the Query object.

Parameters:
  • start_date (str) – The new start date value.

  • end_date (str) – The new end date value.

  • name (str) – A new query name.

status(client: Client = None, id: str = None, poll: bool = True, status_interval: int = 30, verify: bool = True)

A method to check the status of a Query.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • id (str) – A Query ID, if None will use id in object.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should call back.

  • verify (bool) – SSL verification

Raises:

Exception – A ibmpairs.client.Client is not found, the Query failed, error making request to server, the status of the request is not 200.

submit(client: Client = None, verify: bool = True, compact_csv: bool = False)

A method to submit a Query.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

Raises:

Exception – A ibmpairs.client.Client is not found, error making request to server, the status of the request is not 200.

submit_and_check_status(client: Client = None, poll: bool = True, status_interval: int = 30, verify: bool = True, compact_csv: bool = False)

A method to submit and check the status of a Query.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should check for status (seconds).

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

Raises:

Exception – A ibmpairs.client.Client is not found, the Query failed, error making request to server, the status of the request is not 200.

submit_check_status_and_download(client: Client = None, poll: bool = True, status_interval: int = 30, download_folder=None, download_file_name=None, verify: bool = True, compact_csv: bool = False, online: bool = False)

A method to submit a Query check the status then download the result.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should call back.

  • download_folder (str) – A download folder (fixed or relative).

  • download_file_name (str) – A file name for the download.

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

Raises:

Exception – A ibmpairs.client.Client is not found, the Query status failed, the download folder could not be made or identified, the download failed, error making request to server, the status of the request is not 200.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_dict_query_post()

Create a dictionary from the objects structure ready for a POST operation.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

to_json_query_post()

Create a string representation of a json dictionary from the objects structure ready for a POST operation.

Return type:

string

unfavorite(id: str = None, client: Client = None, verify: bool = True)

A method to unfavorite a Query.

Parameters:
  • id (str) – The Query ID to be made not a favorite.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Raises:

Exception – A ibmpairs.client.Client is not found, an ID is not provided or already held in the object, the status of the request is not 200.

class query.QueryHistory(client: Client = None, id: int = None, user: User = None, type: str = None, date: int = None, query_job: str = None, api_json: str = None, size_total: int = None, size_raw: int = None, size_zip: int = None, count_total: int = None)

A representation of a Query History.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • id (int) – The Query ID.

  • user (ibmpairs.query.Query) – The User that Queried.

  • type (str) – Type.

  • date (int) – The date of the query (UNIX).

  • query_job (str) – The Query Job ID.

  • api_json (str) – The JSON request body sent to the API.

  • size_total (int) – The total query size.

  • size_raw (int) – The size of the raw data.

  • size_zip (int) – The size of the query zip.

  • count_total (int) – Count total.

from_dict()

Create a QueryHistory object from a dictionary.

Parameters:

query_history_dict (Any) – A dictionary that contains the keys of a QueryHistory.

Return type:

ibmpairs.query.QueryHistory

Raises:

Exception – if not a dictionary.

from_json()

Create a QueryHistory object from json (dictonary or str).

Parameters:

query_history_dict (Any) – A json dictionary that contains the keys of a QueryHistory or a string representation of a json dictionary.

Return type:

ibmpairs.query.QueryHistory

Raises:

Exception – if not a dictionary or a string.

get(id: str = None, client: Client = None, verify: bool = True)

A method to get a query history result.

Parameters:
  • id (str) – Query ID.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Returns:

A query history result set.

Return type:

ibmpairs.query.QueryHistory

Raises:

Exception – A ibmpairs.client.Client is not found, the status of the request is not 200.

get_query_by_id(id: str = None, client: Client = None, verify: bool = True)

A method to get a Query object that has previously ran by ID.

Parameters:
  • id (str) – Query ID.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Returns:

A query history result set.

Return type:

ibmpairs.query.Query

Raises:

Exception – A ibmpairs.client.Client is not found, the status of the request is not 200.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.QueryJob(id: str = None, status: str = None, start: int = None, sw_lat: float = None, sw_lon: float = None, ne_lat: float = None, ne_lon: float = None, nickname: str = None, ex_percent: int = None, flag: bool = None, hadoop_id: str = None, ready: bool = None, rt_status: str = None, pd_status: str = None, status_code: int = None, message: str = None)

A representation of a Query Job.

Parameters:
  • id (str) – Query ID.

  • status (str) – Query status.

  • start (int) – The start time of the query (UNIX).

  • sw_lat (float) – The south west latitudinal point of the query.

  • sw_lon (float) – The south west longitudinal point of the query.

  • ne_lat (float) – The north east latitudinal point of the query.

  • ne_lon (float) – The north east longitudinal point of the query.

  • nickname (str) – Query name.

  • ex_percent (int) – Execution percentage.

  • flag (bool) – Favorite flag.

  • hadoop_id (str) – YARN Job execution ID.

  • ready (bool) – Query readiness.

  • rt_status (str) – RT status.

  • pd_status (str) – PD status.

  • status_code (int) – Status code.

  • message (str) – Query message.

from_dict()

Create a QueryJob object from a dictionary.

Parameters:

query_job_dict (Any) – A dictionary that contains the keys of a QueryJob.

Return type:

ibmpairs.query.QueryJob

Raises:

Exception – if not a dictionary.

from_json()

Create a QueryJob object from json (dictonary or str).

Parameters:

query_job_dict (Any) – A json dictionary that contains the keys of a QueryJob or a string representation of a json dictionary.

Return type:

ibmpairs.query.QueryJob

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.QueryJobLayer(name: str = None, style: str = None, dataset_id: int = None, dataset: str = None, datalayer_id: str = None, datalayer: str = None, group: str = None, timestamp: int = None, dimensions: List[Dimension] = None, min: float = None, max: float = None, colortable_id: int = None, options: List[str] = None, type: str = None, geoserver_url: str = None, geoserver_ws: str = None, units_bl: str = None)

A representation of a Query Job Layer.

Parameters:
  • name (str) – The name of the Query Job Layer.

  • style (str) – The Query Job Layer style.

  • dataset_id (str) – The Data Set ID.

  • dataset (str) – The Data Set name.

  • datalayer_id (str) – The Data Layer ID.

  • datalayer (str) – The Data Layer name.

  • group (str) – The Data Layer group.

  • timestamp (int) – Timestamp (UNIX).

  • dimensions (List[ibmpairs.query.Dimensions]) – A list of Dimensions that apply.

  • min (int) – The minimum value of the data.

  • max (int) – The maximum value of the data.

  • colortable_id (int) – The Colour Table ID.

  • options (List[str]) – A list of applied options.

  • type (str) – Type.

  • geoserver_url (str) – The GeoServer URL.

  • geoserver_ws (str) – The GeoServer Web Server.

  • units_bl (str) – Units.

from_dict()

Create a QueryJobLayer object from a dictionary.

Parameters:

query_job_layer_dict (Any) – A dictionary that contains the keys of a QueryJobLayer.

Return type:

ibmpairs.query.QueryJobLayer

Raises:

Exception – if not a dictionary.

from_json()

Create a QueryJobLayer object from json (dictonary or str).

Parameters:

query_job_layer_dict (Any) – A json dictionary that contains the keys of a QueryJobLayer or a string representation of a json dictionary.

Return type:

ibmpairs.query.QueryJobLayer

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.QueryJobLayers(query_job_layers: List[QueryJobLayer] = None)

A representation of a list of Query Job Layers.

Parameters:

query_job_layers (List[ibmpairs.query.QueryJobLayer]) – A list of Query Job Layers.

from_dict()

Create a QueryJobLayers object from a dictionary.

Parameters:

query_job_layers_input (Any) – A dictionary that contains the keys of a QueryJobLayers.

Return type:

ibmpairs.query.QueryJobLayers

Raises:

Exception – if not a dictionary.

from_json()

Create a QueryJobLayers object from json (dictonary or str).

Parameters:

query_job_layers_dict (Any) – A json dictionary that contains the keys of a QueryJobLayers or a string representation of a json dictionary.

Return type:

ibmpairs.query.QueryJobLayers

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.QueryJobs(tot_pages: int = None, query_job_list: List[QueryJob] = None)

A representation of a list of Query Jobs.

Parameters:
  • tot_pages (int) – Total pages.

  • query_job_list (List[ibmpairs.query.QueryJob]) – A list of Query jobs.

from_dict()

Create a QueryJobs object from a dictionary.

Parameters:

query_jobs_dict (Any) – A dictionary that contains the keys of a QueryJobs.

Return type:

ibmpairs.query.QueryJobs

Raises:

Exception – if not a dictionary.

from_json()

Create a QueryJobs object from json (dictonary or str).

Parameters:

query_jobs_dict (Any) – A json dictionary that contains the keys of a QueryJobs or a string representation of a json dictionary.

Return type:

ibmpairs.query.QueryJobs

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.QueryOutputInfoFile(name: str = None, dataset_id: int = None, dataset_name: str = None, datalayer_id: str = None, datalayer_name: str = None, datalayer_alias: str = None, temporal_aggregation: str = None, spatial_aggregation: str = None, dimension: str = None, timestamp: str = None, layer_type: str = None)

A representation of the output.info file returned in a Query zip.

from_dict()

Create an QueryOutputInfoFile object from a dictionary.

Parameters:

query_output_info_file_dict (Any) – A dictionary that contains the keys of an QueryOutputInfoFile.

Return type:

ibmpairs.query.QueryOutputInfoFile

Raises:

Exception – if not a dictionary.

from_json()

Create a QueryOutputInfoFile object from json (dictonary or str).

Parameters:

query_output_info_file_dict (Any) – A json dictionary that contains the keys of a QueryOutputInfoFile or a string representation of a json dictionary.

Return type:

ibmpairs.query.QueryOutputInfoFile

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.QueryResponse(id: str = None, url: str = None, data: Any = None, message: str = None)

A representation of a response to a Query.

Parameters:
  • id (str) – Query ID.

  • url (str) – URL.

  • data (List[ibmpairs.query.QueryResponseData] or str) – The data provided by a query response.

  • message (str) – A response message.

from_dict()

Create a QueryResponse object from a dictionary.

Parameters:

query_response_dict (Any) – A dictionary that contains the keys of a QueryResponse.

Return type:

ibmpairs.query.QueryResponse

Raises:

Exception – if not a dictionary.

from_json(compact_csv: bool = False)

Create a QueryResponse object from json (dictonary or str).

Parameters:
  • query_response_dict (Any) – A json dictionary that contains the keys of a QueryResponse or a string representation of a json dictionary.

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

Return type:

ibmpairs.query.QueryResponse

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.QueryResponseData(layer_id: int = None, layer_name: str = None, dataset: str = None, timestamp: int = None, longitude: float = None, latitude: float = None, region: str = None, value: str = None, unit: str = None, pty: str = None, aggregation: str = None, alias: str = None)

A representation of a the data returned by a response to a Query request.

Parameters:
  • layer_id (int) – A query.Layer ID.

  • layer_name (str) – A query.Layer name.

  • dataset (str) – A Data Set ID.

  • timestamp (int) – A timestamp.

  • longitude (float) – Longitude.

  • latitude (float) – Latitude.

  • region (str) – Region.

  • value (str) – Value.

  • unit (str) – Unit of measurement.

  • pty (str) – Property.

  • aggregation (str) – Aggregation.

  • alias (str) – Alias.

from_dict()

Create a QueryResponseData object from a dictionary.

Parameters:

query_response_data_dict (Any) – A dictionary that contains the keys of a QueryResponseData.

Return type:

ibmpairs.query.QueryResponseData

Raises:

Exception – if not a dictionary.

from_json()

Create a QueryResponseData object from json (dictonary or str).

Parameters:

query_response_data_dict (Any) – A json dictionary that contains the keys of a QueryResponseData or a string representation of a json dictionary.

Return type:

ibmpairs.query.QueryResponseData

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Spatial(type: str = None, aoi: str = None, polygon: Polygon = None, coordinates: List[float] = None, aggregation: Aggregation = None, geojson=None)

A representation of a Query Spatial.

Parameters:
  • type (str) – Spatial type.

  • aoi (str) – Area of Interest.

  • polygon (ibmpairs.query.Polygon) – A Query polygon definition.

  • coordinates (list[float]) – A list of coordinates.

  • aggregation (ibmpairs.query.aggregation) – A spatial aggregation definition.

  • geojson (dict or geojson.feature.FeatureCollection or geojson.feature.Feature) – A geojson specification.

from_dict()

Create a Spatial object from a dictionary.

Parameters:

spatial_dict (Any) – A dictionary that contains the keys of a Spatial.

Return type:

ibmpairs.query.Spatial

Raises:

Exception – if not a dictionary.

from_json()

Create a Spatial object from json (dictonary or str).

Parameters:

spatial_dict (Any) – A json dictionary that contains the keys of a Spatial or a string representation of a json dictionary.

Return type:

ibmpairs.query.Spatial

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Temporal(intervals: List[Interval] = None, years: List[int] = None)

A representation of a Query Temporal.

Parameters:
  • intervals (List[ibmpairs.query.Interval]) – A list of temporal intervals.

  • years (List[int]) – A list of years.

from_dict()

Create a Temporal object from a dictionary.

Parameters:

temporal_dict (Any) – A dictionary that contains the keys of a Temporal.

Return type:

ibmpairs.query.Temporal

Raises:

Exception – if not a dictionary.

from_json()

Create a Temporal object from json (dictonary or str).

Parameters:

temporal_dict (Any) – A json dictionary that contains the keys of a Temporal or a string representation of a json dictionary.

Return type:

ibmpairs.query.Temporal

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.Upload(provider: str = None, endpoint: str = None, bucket: str = None, token: str = None)

A representation of a Query Upload.

Parameters:
  • provider (str) – A provider (‘ibm’ or ‘aws’).

  • endpoint (str) – A bucket endpoint.

  • bucket (str) – A bucket name.

  • token (str) – An access token.

from_dict()

Create an Upload object from a dictionary.

Parameters:

upload_dict (Any) – A dictionary that contains the keys of an Upload.

Return type:

ibmpairs.query.Upload

Raises:

Exception – if not a dictionary.

from_json()

Create an Upload object from json (dictonary or str).

Parameters:

upload_dict (Any) – A json dictionary that contains the keys of an Upload or a string representation of a json dictionary.

Return type:

ibmpairs.query.Upload

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

class query.User(id: str = None, login: str = None, group: Group = None, email: str = None, company: str = None, admin: str = None, secondary_groups: List[Group] = None)

A representation of a User.

Parameters:
  • id (int) – The User ID.

  • login (str) – The User login name.

  • group (ibmpairs.query.Group) – A Users primary Group.

  • email (str) – A Users email address.

  • company (str) – The Users company name.

  • admin (str) – Whether a user is an administrator.

  • secondary_groups (List[ibmpairs.query.Group]) – A list of secondary groups to which a user belongs.

from_dict()

Create a User object from a dictionary.

Parameters:

user_dict (Any) – A dictionary that contains the keys of an User.

Return type:

ibmpairs.query.User

Raises:

Exception – if not a dictionary.

from_json()

Create a User object from json (dictonary or str).

Parameters:

user_dict (Any) – A json dictionary that contains the keys of a User or a string representation of a json dictionary.

Return type:

ibmpairs.query.User

Raises:

Exception – if not a dictionary or a string.

to_dict()

Create a dictionary from the objects structure.

Return type:

dict

to_json()

Create a string representation of a json dictionary from the objects structure.

Return type:

string

query.aggregation_from_dict(aggregation_dictionary: dict)

The function converts a dictionary of Aggregation to an Aggregation object.

Parameters:

aggregation_dict (dict) – A dictionary that contains the keys of an Aggregation.

Return type:

ibmpairs.query.Aggregation

Raises:

Exception – if not a dict.

query.aggregation_from_json(aggregation_json: Any)

The function converts a dictionary or json string of Aggregation to an Aggregation object.

Parameters:

aggregation_json (Any) – A dictionary or json string that contains the keys of an Aggregation.

Return type:

ibmpairs.query.Aggregation

Raises:

Exception – if not a dict or a str.

query.aggregation_to_dict(aggregation: Aggregation)

The function converts an object of Aggregation to a dict.

Parameters:

aggregation (ibmpairs.query.Aggregation) – An Aggregation object.

Return type:

dict

query.aggregation_to_json(aggregation: Aggregation)

The function converts an object of Aggregation to a json string.

Parameters:

aggregation (ibmpairs.query.Aggregation) – An Aggregation object.

Return type:

str

query.aoi_from_json(aoi_json: Any, client: Client = None)

The function converts a dictionary or json string of AOI to an AOI object.

Parameters:
  • aoi_json (Any) – A dictionary or json string that contains the keys of an AOI.

  • client (ibmpairs.client.Client) – An IBM PAIRS client.

Return type:

ibmpairs.query.AOI

Raises:

Exception – if not a dict or a str.

query.aoi_to_json(aoi: AOI)

The function converts an object of AOI to a json string.

Parameters:

query (ibmpairs.query.AOI) – An AOI object.

Return type:

str

query.aois_from_json(aois_json: Any, client: Client = None)

The function converts a dictionary or json string of AOIs to an AOIs object.

Parameters:
  • aois_json (Any) – A dictionary or json string that contains the keys of an AOIs.

  • client (ibmpairs.client.Client) – An IBM PAIRS client.

Return type:

ibmpairs.query.AOIs

Raises:

Exception – if not a dict or a str.

query.aois_to_json(aois: AOIs)

The function converts an object of AOIs to a json string.

Parameters:

query (ibmpairs.query.AOIs) – An AOIs object.

Return type:

str

query.batch_query(queries: List[Query], client: Client = None, status_interval: int = 30, workers: int = 1, submit: bool = True, status: bool = True, download: bool = True, verify: bool = True, compact_csv: bool = False, online: bool = False)

A method to gather a number of batched queries using the query_worker method.

Parameters:
  • queries (List[ibmpairs.query.Query]) – A list of queries.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • status_interval (int) – How often the async run operation should call back.

  • workers (int) – How many async operations should run contemporaneously.

  • submit (bool) – Whether submit should be run.

  • status (bool) – Whether status check should be run.

  • download (bool) – Whether download should be run.

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

Returns:

A list of queries.

Return type:

List[ibmpairs.query.Query]

query.check_status_and_download(query: Any = None, client: Client = None, id: str = None, poll: bool = True, status_interval: int = 30, download_folder='download', download_file_name=None, verify: bool = True, online: bool = False)

A helper method to check the status of a query then download the result.

Parameters:
  • query (ibmpairs.query.Query) – A query (must contain ID) to check the status of and download.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • id (str) – A Query ID, if None will use id in object.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should call back.

  • download_folder (str) – A download folder (fixed or relative).

  • download_file_name (str) – A file name for the download.

  • verify (bool) – SSL verification

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

Returns:

A query object.

Return type:

ibmpairs.query.Query

Raises:

Exception – A ibmpairs.client.Client is not found, the Query status failed, the download folder could not be made or identified, the download failed, error making request to server, the status of the request is not 200, the type or format of Query is incorrect.

query.dimension_from_dict(dimension_dictionary: dict)

The function converts a dictionary of Dimension to a Dimension object.

Parameters:

dimension_dict (dict) – A dictionary that contains the keys of a Dimension.

Return type:

ibmpairs.query.Dimension

Raises:

Exception – if not a dict.

query.dimension_from_json(dimension_json: Any)

The function converts a dictionary or json string of Dimension to a Dimension object.

Parameters:

dimension_json (Any) – A dictionary or json string that contains the keys of a Dimension.

Return type:

ibmpairs.query.Dimension

Raises:

Exception – if not a dict or a str.

query.dimension_to_dict(dimension: Dimension)

The function converts an object of Dimension to a dict.

Parameters:

dimension (ibmpairs.query.Dimension) – A Dimension object.

Return type:

dict

query.dimension_to_json(dimension: Dimension)

The function converts an object of Dimension to a json string.

Parameters:

dimension (ibmpairs.query.Dimension) – A Dimension object.

Return type:

str

query.download(query: Any = None, client: Client = None, id: str = None, status_interval: int = 30, download_folder=None, download_file_name=None, verify: bool = True, online: bool = False)

A helper method to download and unzip a query result.

Parameters:
  • query (ibmpairs.query.Query) – A query (must contain ID) to check the status of and download.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • id (str) – A Query ID, if None will use id in object.

  • status_interval (int) – How often the async run operation should call back.

  • download_folder (str) – A download folder (fixed or relative).

  • download_file_name (str) – A file name for the download.

  • verify (bool) – SSL verification

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

Returns:

A query object.

Return type:

ibmpairs.query.Query

Raises:

Exception – A ibmpairs.client.Client is not found, the Query status failed, the download folder could not be made or identified, the download failed, error making request to server, the status of the request is not 200, the type or format of Query is incorrect.

query.favorite(id: str, client: Client = None, verify: bool = True)

A helper method to favorite a Query.

Parameters:
  • id (str) – The Query ID to be made a favorite.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Raises:

Exception – A ibmpairs.client.Client is not found, an ID is not provided or already held in the object, the status of the request is not 200.

query.filter_from_dict(filter_dictionary: dict)

The function converts a dictionary of Filter to a Filter object.

Parameters:

filter_dict (dict) – A dictionary that contains the keys of a Filter.

Return type:

ibmpairs.query.Filter

Raises:

Exception – if not a dict.

query.filter_from_json(filter_json: Any)

The function converts a dictionary or json string of Filter to a Filter object.

Parameters:

filter_json (Any) – A dictionary or json string that contains the keys of a Filter.

Return type:

ibmpairs.query.Filter

Raises:

Exception – if not a dict or a str.

query.filter_to_dict(filter: Filter)

The function converts an object of Filter to a dict.

Parameters:

filter (ibmpairs.query.Filter) – A Filter object.

Return type:

dict

query.filter_to_json(filter: Filter)

The function converts an object of Filter to a json string.

Parameters:

filter (ibmpairs.query.Filter) – A Filter object.

Return type:

str

query.get_aoi(id: int = None, geometry_format: str = 'geojson', client: Client = None, verify: bool = True)

A helper method to get an AOI.

Parameters:
  • id (int) – The AOI ID of the AOI to be gathered.

  • geometry_format (str) – A geometry format, ‘geojson’ or ‘wkt’ (default: geojson)

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Returns:

A populated AOI object.

Return type:

ibmpairs.query.AOI

Raises:

Exception – A ibmpairs.client.Client is not found, an ID is not provided or already held in the object, a server error occurred, the status of the request is not 200.

query.get_aois(search_term: str, client: Client = None, verify: bool = True)

A helper method to get a series of AOIs by a search_term (searches the name field only).

Parameters:
  • search_term (str) – A search on name for the gathered AOIs; by default None (if None, all AOIs).

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Returns:

A populated AOIs object.

Return type:

ibmpairs.query.AOIs

Raises:

Exception – A ibmpairs.client.Client is not found, a server error occurred, the status of the request is not 200.

query.get_latest_favorites(client: Client = None, number_of_queries: int = 10, verify: bool = True)

A helper method to get a list of latest favorite queries.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • number_of_queries (int) – Number of latest queries to gather.

  • verify (bool) – SSL verification

Returns:

A list of the latest favorite queries a user has run.

Return type:

ibmpairs.query.LatestQueries

Raises:

Exception – A ibmpairs.client.Client is not found, the status of the request is not 200, if queries could not be retrieved.

query.get_latest_queries(client: Client = None, favorite_flag: bool = False, number_of_queries: int = 10, verify: bool = True)

A helper method to get a list of latest queries.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • favorite_flag (bool) – Whether only favorites should be searched.

  • number_of_queries (int) – Number of latest queries to gather.

  • verify (bool) – SSL verification

Returns:

A list of the latest queries a user has run.

Return type:

ibmpairs.query.LatestQueries

Raises:

Exception – A ibmpairs.client.Client is not found, the status of the request is not 200, if queries could not be retrieved.

query.get_query_by_id(id: str, client: Client = None, verify: bool = True)

A helper method to get a previously run Query object by an ID number.

Parameters:
  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Returns:

A Query object.

Return type:

ibmpairs.query.Query

Raises:

Exception – A ibmpairs.client.Client is not found, the status of the request is not 200.

query.group_from_dict(group_dictionary: dict)

The function converts a dictionary of Group to a Group object.

Parameters:

group_dict (dict) – A dictionary that contains the keys of a Group.

Return type:

ibmpairs.query.Group

Raises:

Exception – if not a dict.

query.group_from_json(group_json: Any)

The function converts a dictionary or json string of Group to a Group object.

Parameters:

group_json (Any) – A dictionary or json string that contains the keys of a Group.

Return type:

ibmpairs.query.Group

Raises:

Exception – if not a dict or a str.

query.group_to_dict(group: Group)

The function converts an object of Group to a dict.

Parameters:

group (ibmpairs.query.Group) – A Group object.

Return type:

dict

query.group_to_json(group: Group)

The function converts an object of Group to a json string.

Parameters:

group (ibmpairs.query.Group) – A Group object.

Return type:

str

query.interval_from_dict(interval_dictionary: dict)

The function converts a dictionary of Interval to an Interval object.

Parameters:

interval_dict (dict) – A dictionary that contains the keys of an Interval.

Return type:

ibmpairs.query.Interval

Raises:

Exception – if not a dict.

query.interval_from_json(interval_json: Any)

The function converts a dictionary or json string of Interval to an Interval object.

Parameters:

interval_json (Any) – A dictionary or json string that contains the keys of an Interval.

Return type:

ibmpairs.query.Interval

Raises:

Exception – if not a dict or a str.

query.interval_to_dict(interval: Interval)

The function converts an object of Interval to a dict.

Parameters:

interval (ibmpairs.query.Interval) – An Interval object.

Return type:

dict

query.interval_to_json(interval: Interval)

The function converts an object of Interval to a json string.

Parameters:

interval (ibmpairs.query.Interval) – An Interval object.

Return type:

str

query.latest_queries_from_dict(latest_queries_dictionary: dict, client: Client = None)

The function converts a dictionary of LatestQueries to a LatestQueries object.

Parameters:
  • latest_queries_dict (dict) – A dictionary that contains the keys of a LatestQueries.

  • client (ibmpairs.client.Client) – An IBM PAIRS client.

Return type:

ibmpairs.query.LatestQueries

Raises:

Exception – if not a dict.

query.latest_queries_from_json(latest_queries_json: Any, client: Client = None)

The function converts a dictionary or json string of LatestQueries to a LatestQueries object.

Parameters:
  • latest_queries_json (Any) – A dictionary or json string that contains the keys of a LatestQueries.

  • client (ibmpairs.client.Client) – An IBM PAIRS client.

Return type:

ibmpairs.query.LatestQueries

Raises:

Exception – if not a dict or a str.

query.latest_queries_to_dict(latest_queries: LatestQueries)

The function converts an object of LatestQueries to a dict.

Parameters:

latest_queries (ibmpairs.query.LatestQueries) – A LatestQueries object.

Return type:

dict

query.latest_queries_to_json(latest_queries: LatestQueries)

The function converts an object of LatestQueries to a json string.

Parameters:

latest_queries (ibmpairs.query.LatestQueries) – A LatestQueries object.

Return type:

str

query.layer_from_dict(layer_dictionary: dict)

The function converts a dictionary of Layer to a Layer object.

Parameters:

layer_dict (dict) – A dictionary that contains the keys of a Layer.

Return type:

ibmpairs.query.Layer

Raises:

Exception – if not a dict.

query.layer_from_dict_post(layer_dictionary: dict)

The function converts a dictionary of Layer to a Layer object.

Parameters:

layer_dict (dict) – A dictionary that contains the keys of a Layer.

Return type:

ibmpairs.query.Layer

Raises:

Exception – if not a dict.

query.layer_from_json(layer_json: Any)

The function converts a dictionary or json string of Layer to a Layer object.

Parameters:

layer_json (Any) – A dictionary or json string that contains the keys of a Layer.

Return type:

ibmpairs.query.Layer

Raises:

Exception – if not a dict or a str.

query.layer_from_json_post(layer_json: Any)

The function converts a dictionary or json string of Layer to a Layer object, ready for post.

Parameters:

layer_json (Any) – A dictionary or json string that contains the keys of a Layer.

Return type:

ibmpairs.query.Layer

Raises:

Exception – if not a dict or a str.

query.layer_to_dict(layer: Layer)

The function converts an object of Layer to a dict.

Parameters:

layer (ibmpairs.query.Layer) – A Layer object.

Return type:

dict

query.layer_to_json(layer: Layer)

The function converts an object of Layer to a json string.

Parameters:

layer (ibmpairs.query.Layer) – A Layer object.

Return type:

str

query.merge_query_into_base(other_job_id, base_job_id=None, client: Client = None, verify: bool = True)

A helper method to merge a query into a base query on the server side.

Parameters:
  • other_job_id (str or int) – The ID of the job to be merged.

  • base_job_id (str or int) – The ID of the base job to be merged to.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Returns:

A query object.

Return type:

ibmpairs.query.Query

Raises:

Exception – A ibmpairs.client.Client is not found, other job ID is not provided, base job ID is not provided or already held in the object, the status of the request is not 200.

query.notification_from_dict(notification_dictionary: dict)

The function converts a dictionary of Notification to a Notification object.

Parameters:

notification_dict (dict) – A dictionary that contains the keys of a Notification.

Return type:

ibmpairs.query.Notification

Raises:

Exception – if not a dict.

query.notification_from_json(notification_json: Any)

The function converts a dictionary or json string of Notification to a Notification object.

Parameters:

notification_json (Any) – A dictionary or json string that contains the keys of a Notification.

Return type:

ibmpairs.query.Notification

Raises:

Exception – if not a dict or a str.

query.notification_to_dict(notification: Notification)

The function converts an object of Notification to a dict.

Parameters:

notification (ibmpairs.query.Notification) – A Notification object.

Return type:

dict

query.notification_to_json(notification: Notification)

The function converts an object of Notification to a json string.

Parameters:

notification (ibmpairs.query.Notification) – A Notification object.

Return type:

str

query.polygon_from_dict(polygon_dictionary: dict)

The function converts a dictionary of Polygon to a Polygon object.

Parameters:

polygon_dict (dict) – A dictionary that contains the keys of a Polygon.

Return type:

ibmpairs.query.Polygon

Raises:

Exception – if not a dict.

query.polygon_from_json(polygon_json: Any)

The function converts a dictionary or json string of Polygon to a Polygon object.

Parameters:

polygon_json (Any) – A dictionary or json string that contains the keys of a Polygon.

Return type:

ibmpairs.query.Polygon

Raises:

Exception – if not a dict or a str.

query.polygon_to_dict(polygon: Polygon)

The function converts an object of Polygon to a dict.

Parameters:

polygon (ibmpairs.query.Polygon) – A Polygon object.

Return type:

dict

query.polygon_to_json(polygon: Polygon)

The function converts an object of Polygon to a json string.

Parameters:

polygon (ibmpairs.query.Polygon) – A Polygon object.

Return type:

str

query.query_from_dict(query_dictionary: dict, client: Client = None)

The function converts a dictionary of Query to a Query object.

Parameters:
  • query_dict (dict) – A dictionary that contains the keys of a Query.

  • client (ibmpairs.client.Client) – An IBM PAIRS client.

Return type:

ibmpairs.query.Query

Raises:

Exception – if not a dict.

query.query_from_json(query_json: Any, client: Client = None)

The function converts a dictionary or json string of Query to a Query object.

Parameters:
  • query_json (Any) – A dictionary or json string that contains the keys of a Query.

  • client (ibmpairs.client.Client) – An IBM PAIRS client.

Return type:

ibmpairs.query.Query

Raises:

Exception – if not a dict or a str.

query.query_history_from_dict(query_history_dictionary: dict, client: Client = None)

The function converts a dictionary of QueryHistory to a QueryHistory object.

Parameters:
  • query_history_dict (dict) – A dictionary that contains the keys of a QueryHistory.

  • client (ibmpairs.client.Client) – An IBM PAIRS client.

Return type:

ibmpairs.query.QueryHistory

Raises:

Exception – if not a dict.

query.query_history_from_json(query_history_json: Any, client: Client = None)

The function converts a dictionary or json string of QueryHistory to a QueryHistory object.

Parameters:
  • query_history_json (Any) – A dictionary or json string that contains the keys of a QueryHistory.

  • client (ibmpairs.client.Client) – An IBM PAIRS client.

Return type:

ibmpairs.query.QueryHistory

Raises:

Exception – if not a dict or a str.

query.query_history_to_dict(query_history: QueryHistory)

The function converts an object of QueryHistory to a dict.

Parameters:

query_history (ibmpairs.query.QueryHistory) – A QueryHistory object.

Return type:

dict

query.query_history_to_json(query_history: QueryHistory)

The function converts an object of QueryHistory to a json string.

Parameters:

query_history (ibmpairs.query.QueryHistory) – A QueryHistory object.

Return type:

str

query.query_job_from_dict(query_job_dictionary: dict)

The function converts a dictionary of QueryJob to a QueryJob object.

Parameters:

query_job_dict (dict) – A dictionary that contains the keys of a QueryJob.

Return type:

ibmpairs.query.QueryJob

Raises:

Exception – if not a dict.

query.query_job_from_json(query_job_json: Any)

The function converts a dictionary or json string of QueryJob to a QueryJob object.

Parameters:

query_job_json (Any) – A dictionary or json string that contains the keys of a QueryJob.

Return type:

ibmpairs.query.QueryJob

Raises:

Exception – if not a dict or a str.

query.query_job_layer_from_dict(query_job_layer_dictionary: dict)

The function converts a dictionary of QueryJobLayer to a QueryJobLayer object.

Parameters:

query_job_layer_dict (dict) – A dictionary that contains the keys of a QueryJobLayer.

Return type:

ibmpairs.query.QueryJobLayer

Raises:

Exception – if not a dict.

query.query_job_layer_from_json(query_job_layer_json: Any)

The function converts a dictionary or json string of QueryJobLayer to a QueryJobLayer object.

Parameters:

query_job_layer_json (Any) – A dictionary or json string that contains the keys of a QueryJobLayer.

Return type:

ibmpairs.query.QueryJobLayer

Raises:

Exception – if not a dict or a str.

query.query_job_layer_to_dict(query_job_layer: QueryJobLayer)

The function converts an object of QueryJobLayer to a dict.

Parameters:

query_job_layer (ibmpairs.query.QueryJobLayer) – A QueryJobLayer object.

Return type:

dict

query.query_job_layer_to_json(query_job_layer: QueryJobLayer)

The function converts an object of QueryJobLayer to a json string.

Parameters:

query_job_layer (ibmpairs.query.QueryJobLayer) – A QueryJobLayer object.

Return type:

str

query.query_job_layers_from_dict(query_job_layers_dictionary: dict)

The function converts a dictionary of QueryJobLayers to a QueryJobLayers object.

Parameters:

query_job_layers_dict (dict) – A dictionary that contains the keys of a QueryJobLayers.

Return type:

ibmpairs.query.QueryJobLayers

Raises:

Exception – if not a dict.

query.query_job_layers_from_json(query_job_layers_json: Any)

The function converts a dictionary or json string of QueryJobLayers to a QueryJobLayers object.

Parameters:

query_job_layers_json (Any) – A dictionary or json string that contains the keys of a QueryJobLayers.

Return type:

ibmpairs.query.QueryJobLayers

Raises:

Exception – if not a dict or a str.

query.query_job_layers_to_dict(query_job_layers: QueryJobLayers)

The function converts an object of QueryJobLayers to a dict.

Parameters:

query_job_layers (ibmpairs.query.QueryJobLayers) – A QueryJobLayers object.

Return type:

dict

query.query_job_layers_to_json(query_job_layers: QueryJobLayers)

The function converts an object of QueryJobLayers to a json string.

Parameters:

query_job_layers (ibmpairs.query.QueryJobLayers) – A QueryJobLayers object.

Return type:

str

query.query_job_to_dict(query_job: QueryJob)

The function converts an object of QueryJob to a dict.

Parameters:

query_job (ibmpairs.query.QueryJob) – A QueryJob object.

Return type:

dict

query.query_job_to_json(query_job: QueryJob)

The function converts an object of QueryJob to a json string.

Parameters:

query_job (ibmpairs.query.QueryJob) – A QueryJob object.

Return type:

str

query.query_jobs_from_dict(query_jobs_dictionary: dict)

The function converts a dictionary of QueryJobs to a QueryJobs object.

Parameters:

query_jobs_dict (dict) – A dictionary that contains the keys of a QueryJobs.

Return type:

ibmpairs.query.QueryJobs

Raises:

Exception – if not a dict.

query.query_jobs_from_json(query_jobs_json: Any)

The function converts a dictionary or json string of QueryJobs to a QueryJobs object.

Parameters:

query_jobs_json (Any) – A dictionary or json string that contains the keys of a QueryJobs.

Return type:

ibmpairs.query.QueryJobs

Raises:

Exception – if not a dict or a str.

query.query_jobs_to_dict(query_jobs: QueryJobs)

The function converts an object of QueryJobs to a dict.

Parameters:

query_jobs (ibmpairs.query.QueryJobs) – A QueryJobs object.

Return type:

dict

query.query_jobs_to_json(query_jobs: QueryJobs)

The function converts an object of QueryJobs to a json string.

Parameters:

query_jobs (ibmpairs.query.QueryJobs) – A QueryJobs object.

Return type:

str

query.query_output_info_file_from_dict(query_output_info_file_dictionary: dict)

The function converts a dictionary of QueryOutputInfoFile to a QueryOutputInfoFile object.

Parameters:

query_output_info_file_dict (dict) – A dictionary that contains the keys of a QueryOutputInfoFile.

Return type:

ibmpairs.query.QueryOutputInfoFile

Raises:

Exception – if not a dict.

query.query_output_info_file_from_json(query_output_info_file_json: Any)

The function converts a dictionary or json string of QueryOutputInfoFile to a QueryOutputInfoFile object.

Parameters:

query_output_info_file_json (Any) – A dictionary or json string that contains the keys of a QueryOutputInfoFile.

Return type:

ibmpairs.query.QueryOutputInfoFile

Raises:

Exception – if not a dict or a str.

query.query_output_info_file_to_dict(query_output_info_file: QueryOutputInfoFile)

The function converts an object of QueryOutputInfoFile to a dict.

Parameters:

query_output_info_file (ibmpairs.query.QueryOutputInfoFile) – A QueryOutputInfoFile object.

Return type:

dict

query.query_output_info_file_to_json(query_output_info_file: QueryOutputInfoFile)

The function converts an object of QueryOutputInfoFile to a json string.

Parameters:

query_output_info_file (ibmpairs.query.QueryOutputInfoFile) – A QueryOutputInfoFile object.

Return type:

str

query.query_response_data_from_dict(query_response_data_dictionary: dict)

The function converts a dictionary of QueryResponseData to a QueryResponseData object.

Parameters:

query_response_data_dict (dict) – A dictionary that contains the keys of a QueryResponseData.

Return type:

ibmpairs.query.QueryResponseData

Raises:

Exception – if not a dict.

query.query_response_data_from_json(query_response_data_json: Any)

The function converts a dictionary or json string of QueryResponseData to a QueryResponseData object.

Parameters:

query_response_data_json (Any) – A dictionary or json string that contains the keys of a QueryResponseData.

Return type:

ibmpairs.query.QueryResponseData

Raises:

Exception – if not a dict or a str.

query.query_response_data_to_dict(query_response_data: QueryResponseData)

The function converts an object of QueryResponseData to a dict.

Parameters:

query_response_data (ibmpairs.query.QueryResponseData) – A QueryResponseData object.

Return type:

dict

query.query_response_data_to_json(query_response_data: QueryResponseData)

The function converts an object of QueryResponseData to a json string.

Parameters:

query_response_data (ibmpairs.query.QueryResponseData) – A QueryResponseData object.

Return type:

str

query.query_response_from_dict(query_response_dictionary: dict)

The function converts a dictionary of QueryResponse to a QueryResponse object.

Parameters:

query_response_dict (dict) – A dictionary that contains the keys of a QueryResponse.

Return type:

ibmpairs.query.QueryResponse

Raises:

Exception – if not a dict.

query.query_response_from_json(query_response_json: Any, compact_csv: bool = False)

The function converts a dictionary or json string of QueryResponse to a QueryResponse object.

Parameters:
  • query_response_json (Any) – A dictionary or json string that contains the keys of a QueryResponse.

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

Return type:

ibmpairs.query.QueryResponse

Raises:

Exception – if not a dict or a str.

query.query_response_to_dict(query_response: QueryResponse)

The function converts an object of QueryResponse to a dict.

Parameters:

query_response (ibmpairs.query.QueryResponse) – A QueryResponse object.

Return type:

dict

query.query_response_to_json(query_response: QueryResponse)

The function converts an object of QueryResponse to a json string.

Parameters:

query_response (ibmpairs.query.QueryResponse) – A QueryResponse object.

Return type:

str

query.query_to_dict(query: Query)

The function converts an object of Query to a dict.

Parameters:

query (ibmpairs.query.Query) – A Query object.

Return type:

dict

query.query_to_dict_post(query: Query)

The function converts an object of Query to a dict, ready for post.

Parameters:

query (ibmpairs.query.Query) – A Query object.

Return type:

dict

query.query_to_json(query: Query)

The function converts an object of Query to a json string.

Parameters:

query (ibmpairs.query.Query) – A Query object.

Return type:

str

query.query_to_json_post(query: Query)

The function converts an object of Query to a json string, ready to post.

Parameters:

query (ibmpairs.query.Query) – A Query object.

Return type:

str

async query.query_worker(queries: List[Query], client: Client, status_interval: int = 30, workers: int = 1, submit: bool = True, status: bool = True, download: bool = True, verify: bool = True, compact_csv: bool = False, online: bool = False)

An asynchronous method to operate and await a number of submit, status and download calls.

Parameters:
  • queries (List[ibmpairs.query.Query]) – A list of queries.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • status_interval (int) – How often the async run operation should call back.

  • workers (int) – How many async operations should run contemporaneously.

  • submit (bool) – Whether submit should be run.

  • status (bool) – Whether status check should be run.

  • download (bool) – Whether download should be run.

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

Returns:

A list of queries.

Return type:

List[ibmpairs.query.Query]

query.search_aois(search_term: str, client: Client = None, verify: bool = True)

A helper method to search all available AOIs against all metadata fields.

Parameters:
  • search_term (str) – A term to search on id, key, name, hierarchy and description for the gathered AOIs.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Returns:

A pandas.DataFrame of AOIs that match the search term.

Return type:

pandas.DataFrame

Raises:

Exception – A ibmpairs.client.Client is not found, a server error occurred, the status of the request is not 200.

query.spatial_from_dict(spatial_dictionary: dict)

The function converts a dictionary of Spatial to a Spatial object.

Parameters:

spatial_dict (dict) – A dictionary that contains the keys of a Spatial.

Return type:

ibmpairs.query.Spatial

Raises:

Exception – if not a dict.

query.spatial_from_json(spatial_json: Any)

The function converts a dictionary or json string of Spatial to a Spatial object.

Parameters:

spatial_json (Any) – A dictionary or json string that contains the keys of a Spatial.

Return type:

ibmpairs.query.Spatial

Raises:

Exception – if not a dict or a str.

query.spatial_to_dict(spatial: Spatial)

The function converts an object of Spatial to a dict.

Parameters:

spatial (ibmpairs.query.Spatial) – A Spatial object.

Return type:

dict

query.spatial_to_json(spatial: Spatial)

The function converts an object of Spatial to a json string.

Parameters:

spatial (ibmpairs.query.Spatial) – A Spatial object.

Return type:

str

query.status(query: Any = None, client: Client = None, id: str = None, poll: bool = True, status_interval: int = 30, verify: bool = True)

A helper method to check the status of a query.

Parameters:
  • query (ibmpairs.query.Query or dict or str) – A query (must contain ID) to check the status of.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • id (str) – A Query ID, if None will use id in object.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should call back.

  • verify (bool) – SSL verification

Returns:

A query object.

Return type:

ibmpairs.query.Query

Raises:

Exception – A ibmpairs.client.Client is not found, the Query failed, error making request to server, the status of the request is not 200, the type or format of Query is incorrect.

query.submit(query: Any, client: Client = None, verify: bool = True, compact_csv: bool = False)

A helper method to submit a query.

Parameters:
  • query (ibmpairs.query.Query or dict or str) – A query to submit.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

Returns:

A query object.

Return type:

ibmpairs.query.Query

Raises:

Exception – A ibmpairs.client.Client is not found, error making request to server, the status of the request is not 200, the type or format of Query is incorrect.

query.submit_and_check_status(query: Any, client: Client = None, poll: bool = True, status_interval: int = 30, verify: bool = True, compact_csv: bool = False)

A helper method to submit and check the status of a query.

Parameters:
  • query (ibmpairs.query.Query or dict or str) – A query to submit.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should check for status (seconds).

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

Returns:

A query object.

Return type:

ibmpairs.query.Query

Raises:

Exception – A ibmpairs.client.Client is not found, the Query failed, error making request to server, the status of the request is not 200, the type or format of Query is incorrect.

query.submit_check_status_and_download(query: Any, client: Client = None, poll: bool = True, status_interval: int = 30, download_folder=None, download_file_name=None, verify: bool = True, compact_csv: bool = False, online: bool = False)

A helper method to submit a query check the status then download the result.

Parameters:
  • query (ibmpairs.query.Query or dict or str) – A query to submit, check the status of and download.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • poll (bool) – Whether the operation should poll until success.

  • status_interval (int) – How often the async run operation should call back.

  • download_folder (str) – A download folder (fixed or relative).

  • download_file_name (str) – A file name for the download.

  • verify (bool) – SSL verification

  • compact_csv (bool) – A flag to indicate the return of a compact csv format.

  • online (bool) – Whether a point queries data should be returned to submit_response.data.

Returns:

A query object.

Return type:

ibmpairs.query.Query

Raises:

Exception – A ibmpairs.client.Client is not found, the Query status failed, the download folder could not be made or identified, the download failed, error making request to server, the status of the request is not 200, the type or format of Query is incorrect.

query.temporal_from_dict(temporal_dictionary: dict)

The function converts a dictionary of Temporal to a Temporal object.

Parameters:

temporal_dict (dict) – A dictionary that contains the keys of a Temporal.

Return type:

ibmpairs.query.Temporal

Raises:

Exception – if not a dict.

query.temporal_from_json(temporal_json: Any)

The function converts a dictionary or json string of Temporal to a Temporal object.

Parameters:

temporal_json (Any) – A dictionary or json string that contains the keys of a Temporal.

Return type:

ibmpairs.query.Temporal

Raises:

Exception – if not a dict or a str.

query.temporal_to_dict(temporal: Temporal)

The function converts an object of Temporal to a dict.

Parameters:

temporal (ibmpairs.query.Temporal) – A Temporal object.

Return type:

dict

query.temporal_to_json(temporal: Temporal)

The function converts an object of Temporal to a json string.

Parameters:

temporal (ibmpairs.query.Temporal) – A Temporal object.

Return type:

str

query.unfavorite(id: str, client: Client = None, verify: bool = True)

A helper method to unfavorite a Query.

Parameters:
  • id (str) – The Query ID to be made not a favorite.

  • client (ibmpairs.client.Client) – An IBM PAIRS Client.

  • verify (bool) – SSL verification

Raises:

Exception – A ibmpairs.client.Client is not found, an ID is not provided or already held in the object, the status of the request is not 200.

query.upload_from_dict(upload_dictionary: dict)

The function converts a dictionary of Upload to a Upload object.

Parameters:

upload_dict (dict) – A dictionary that contains the keys of a Upload.

Return type:

ibmpairs.query.Upload

Raises:

Exception – if not a dict.

query.upload_from_json(upload_json: Any)

The function converts a dictionary or json string of Upload to a Upload object.

Parameters:

upload_json (Any) – A dictionary or json string that contains the keys of a Upload.

Return type:

ibmpairs.query.Upload

Raises:

Exception – if not a dict or a str.

query.upload_to_dict(upload: Upload)

The function converts an object of Upload to a dict.

Parameters:

upload (ibmpairs.query.Upload) – A Upload object.

Return type:

dict

query.upload_to_json(upload: Upload)

The function converts an object of Upload to a json string.

Parameters:

upload (ibmpairs.query.Upload) – A Upload object.

Return type:

str

query.user_from_dict(user_dictionary: dict)

The function converts a dictionary of User to a User object.

Parameters:

user_dict (dict) – A dictionary that contains the keys of a User.

Return type:

ibmpairs.query.User

Raises:

Exception – if not a dict.

query.user_from_json(user_json: Any)

The function converts a dictionary or json string of User to a User object.

Parameters:

user_json (Any) – A dictionary or json string that contains the keys of a User.

Return type:

ibmpairs.query.User

Raises:

Exception – if not a dict or a str.

query.user_to_dict(user: User)

The function converts an object of User to a dict.

Parameters:

user (ibmpairs.query.User) – A User object.

Return type:

dict

query.user_to_json(user: User)

The function converts an object of User to a json string.

Parameters:

user (ibmpairs.query.User) – A User object.

Return type:

str