Client¶
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 client.Client(host: str = None, headers: dict = None, authentication=None, body: str = None, client_id: str = None, tenant_id: str = None, legacy: bool = None, version: int = None)¶
A client wrapper for interaction with IBM PAIRS.
- Parameters:
host (str) – IBM PAIRS host.
headers (dict) – A dictionary of request headers.
authentication (ibmpairs.authentication.Oauth2 or ibmpairs.authentication.Basic) – An authentication object.
body (str) – A message body.
client_id (str) – A client id for the authentication system, defaults to ‘ibm-pairs’ if legacy.
tenant_id (str) – IBM EIS GA API Connect Tenant Id
legacy (bool) – IBM EIS GA Legacy Environment selector override
version (int) – IBM EIS GA api version (default: 3)
- async async_get(url, session: ClientSession = None, authentication=None, headers=None, verify=None, response_type='json')¶
A wrapper method around aiohttp.ClientSession.get.
- Parameters:
url (str) – A URL to GET.
session (aiohttp.ClientSession) – An aiohttp.ClientSession to use for a GET request.
authentication (ibmpairs.authentication.Basic or ibmpairs.authentication.OAuth2) – A username for the user.
headers (dict) – A dictionary of request headers.
verify (bool) – Verify SSL.
response_type (str) – A response type, defaults to json.
- Returns:
An ibmpairs.client.ClientResponse object.
- Return type:
ibmpairs.client.ClientResponse
- async async_post(url, body, session: ClientSession = None, authentication=None, headers=None, verify=None)¶
A wrapper method around aiohttp.ClientSession.post.
- Parameters:
url (str) – A URL to POST.
body (Any) – A body for the POST request.
session (aiohttp.ClientSession) – An aiohttp.ClientSession to use for a get request.
authentication (ibmpairs.authentication.Basic or ibmpairs.authentication.OAuth2) – A username for the user.
headers (dict) – A dictionary of request headers.
verify (bool) – Verify SSL.
- Returns:
An ibmpairs.client.ClientResponse object.
- Return type:
ibmpairs.client.ClientResponse
- static authentication_mode(a)¶
A wrapper method to determine authentication type.
- Parameters:
a (Any) – authentication
- Returns:
An authentication type string.
- Return type:
str
- delete(url, headers=None, verify=True)¶
A wrapper method around requests.delete.
- Parameters:
url (str) – A URL to DELETE.
headers (dict) – A dictionary of request headers.
verify (bool) – Verify SSL.
- Returns:
A requests.Response object.
- Return type:
requests.Response
- get(url, headers=None, verify=True)¶
A wrapper method around requests.get.
- Parameters:
url (str) – A URL to GET.
headers (dict) – A dictionary of request headers.
verify (bool) – Verify SSL.
- Returns:
A requests.Response object.
- Return type:
requests.Response
- post(url, body, headers=None, verify=True)¶
A wrapper method around requests.post.
- Parameters:
url (str) – A URL to POST.
body (Any) – A body for the POST request.
headers (dict) – A dictionary of request headers.
verify (bool) – Verify SSL.
- Returns:
A requests.Response object.
- Return type:
requests.Response
- put(url, body=None, headers=None, verify=True)¶
A wrapper method around requests.put.
- Parameters:
url (str) – A URL to PUT.
body (Any) – A body for the PUT request.
headers (dict) – A dictionary of request headers.
verify (bool) – Verify SSL.
- Returns:
A requests.Response object.
- Return type:
requests.Response
- session(authentication=None, headers=None, verify=None)¶
A wrapper method around aiohttp.ClientSession.
- Parameters:
authentication (ibmpairs.authentication.Basic or ibmpairs.authentication.OAuth2) – A username for the user.
headers (dict) – A dictionary of request headers.
verify (bool) – Verify SSL.
- Returns:
A aiohttp.ClientSession using the attributes provided.
- Return type:
aiohttp.ClientSession
- class client.ClientResponse(status: int = None, body: str = None)¶
A representation of a client response.
- Parameters:
status – A response status.
body (str or bytes) – A response body.
- client.get_client(host: str = None, username: str = None, api_key: str = None, api_key_file: str = 'auth/oauth2.txt', client_id: str = None, endpoint: str = None, jwt_token: str = None, iam_endpoint: str = 'iam.cloud.ibm.com', org_id: str = None, tenant_id: str = None, headers: dict = None, body: str = None, password: str = None, password_file: str = None, legacy: bool = None, version: int = None)¶
Gets either a authentication.Basic or authentication.OAuth2 from authentication credentials.
- Parameters:
host (str) – IBM PAIRS host
username (str) – IBM PAIRS username
api_key (str) – IBM PAIRS API key
api_key_file (str) – IBM PAIRS API key file, defaults to auth/oauth2.txt
client_id (str) – A client id for the authentication system, defaults to ‘ibm-pairs’ if legacy.
endpoint (str) – The authentication endpoint.
jwt_token (str) – A jwt token for authentication.
iam_endpoint (str) – IBM Cloud IAM Endpoint
org_id (str) – IBM EIS GA API Connect Org Id
tenant_id (str) – IBM EIS GA API Connect Tenant Id
password (str) – IBM PAIRS password
password_file (str) – IBM PAIRS password file, defaults to auth/basic.txt
legacy (bool) – IBM EIS GA Legacy Environment selector override
version (int) – IBM EIS GA api version (default: 3)
- Return type:
- Raises:
Exception – if authentication.Basic or authentication.OAuth2 raise an error