Maximo API Class — pynexusic 2.5.0 documentation

# Maximo API Class

Maximo API class allows the user to communicate with Maximo REST API using python

Prerequisites:

- Python > 3.7

- Maximo access

class MAXIMO_API.MAXIMO_REST(base_url, username=None, password=None, api_key=None, authentication_type='LDAP BASIC', max_attempts=1, timeout=None, mif=False, verbose=False, verify=True, logger=None)
  Parameters

    - maximo_url – (`string`) - Maximo URL

    - username – (`string` - optional) - Default value None

    - password – (`string` - optional) - Default value None

    - api_key – (`string` - optional) - Default value None

    - authentication_type – (`string` - optional) - The only value supported LDAP BASIC (default value LDAP BASIC)

    - max_attempts – (`int` - optional) - Maximum number of attempts if disconnected (default value 1)

    - timeout – (`int` - optional) - Timeout threshold in seconds (default value None)

    - mif – (`bool` - optional) - True if maximo_mif to be used, False if maximo to be used in the URL (default value False)

    - verbose – (`bool` - optional) - Print internal messages if True (default value False)

    - verify – (`bool` - optional) - By pass SSL verification if True (default value True)

    - logger – (`Logger` - optional) - Logger object used to export information to a log file (default value None)

  Returns

    None

  add_param_to_url(url, param, value)
  authenticate(verbose=False)

    Authenticate with Maximo using the defined authentication type used in the class constructor

    Parameters

      verbose – (`bool` - optional) - Print internal messages if True (default value False).

    Returns

      None

  generate_base64(value)

    Generate base64 string

    Parameters

      value – (`string`) - String value to be converted to base64.

    Returns

      (`String`) - base64 string.

  get_mx_srs(select_fields='*', where=None, orderBy=None, gbcols=None, oslc=True, pageSize=100)

    Execute query and get Service Requests.

    Parameters

      - select_fields – (`string` - optional) - Fields included in the query (default value *)

      - where – (`string` - optional) - Where condition to be included in the query (default value None)

      - orderBy – (`string` - optional) - Field(s) to order data (default value None). + sign indicated ascending and - sign indicates descending

      - gbcols – (`string` - optional) - Group by columns condition to aggregate data (default value None). See https://www.imwuc.org/HigherLogic/System/DownloadDocumentFile.ashx?DocumentFileKey=f29fb7ba-5917-f2a9-e599-9161e5d14582

      - oslc – (`bool` - optional) - Defines whether to use oslc protocol or not (default value True)

      - pageSize – (`int` - optional) - Page size for response (default value None). When default is used the default Maximo page size will be used (1000).

    Returns

      (`tuple` - dict or string, string) - response (json or error string) and response status code.

  get_mx_wos(select_fields='*', where=None, orderBy=None, gbcols=None, oslc=True, pageSize=100)

    Execute query and get WOs.

    Parameters

      - select_fields – (`string` - optional) - Fields included in the query (default value *)

      - where – (`string` - optional) - Where condition to be included in the query (default value None)

      - orderBy – (`string` - optional) - Field(s) to order data (default value None). + sign indicated ascending and - sign indicates descending

      - gbcols – (`string` - optional) - Group by columns condition to aggregate data (default value None). See https://www.imwuc.org/HigherLogic/System/DownloadDocumentFile.ashx?DocumentFileKey=f29fb7ba-5917-f2a9-e599-9161e5d14582

      - oslc – (`bool` - optional) - Defines whether to use oslc protocol or not (default value True)

      - pageSize – (`int` - optional) - Page size for response (default value None). When default is used the default Maximo page size will be used (1000).

    Returns

      (`tuple` - dict or string, string) - response (json or error string) and response status code.

  mbo_create_new_record(tableName, parameters, verbose=False)

    Create a new record in a specific table in Maximo.

    Parameters

      - tableName – (`string`) - Maximo table name

      - parameters – (`dict`) - Field names (dict keys) and values (dict values) to be inserted

      - verbose – (`bool` - optional) - Print internal messages if True (default value False).

    Returns

      (`tuple` - dict or string, string) - response (json or error string) and response status code.

  mbo_exec_method(tableName, tableID, method, method_parameters=None, verbose=False)

    Execute a method on a specific MBO in Maximo.

    Parameters

      - tableName – (`string`) - Maximo table name

      - tableID – (`int`) - Primary key record ID

      - method – (`string`) - Name of the method to be executed

      - method_parameters – (`dict`) - Method parameters

      - verbose – (`bool` - optional) - Print internal messages if True (default value False).

    Returns

      (`tuple` - dict or string, string) - response (json or error string) and response status code.

  mbo_get_table(tableName, includecols=None, excludecols=None, orderbyasc=None, orderbydesc=None, where=None, maxItems=None, format='json', compact=1, verbose=False, current_attempt=1)

    Get data from a specific table in Maximo using REST API. https://maximo.bia.gov/help/index.jsp?topic=/com.ibm.mif.doc/gp_intfrmwk/rest_api/r_rest_post_method.html

    Parameters

      - tableName – (`string`) - Maximo table name

      - includecols – (`string` - optional) - Comma-separated list of MBO attributes. Includes the listed attributes from the resource response (default value None).

      - excludecols – (`string` - optional) - Comma-separated list of MBO attributes. Excludes the listed attributes from the resource response (default value None).

      - orderbyasc – (`string` - optional) - Comma-separated list of MBO attributes. Specifies the attributes that are used for the order by clause in ascending order (default value None).

      - orderbydesc – (`string` - optional) - Comma-separated list of MBO attributes. Specifies the attributes that are used for the order by clause in descending order (default value None).

      - where – (`string` - optional) - Where condition to filter data (default value None).

      - maxItems – (`int` - optional) - Specifies the maximum number of business objects that are serialized in the resource collection (default value None).

      - format – (`string` - optional) - Specifies the representation of the resource response (default value json). Could be either json or xml.

      - compact – (`int` - optional) - If true, JSON data is represented in a compact representation (default value 1).

      - verbose – (`bool` - optional) - Print internal messages if True (default value False).

      - current_attempt – (`int` - don’t use) - This argument is intended for internal method use only.

    Returns

      (`tuple` - dict or string, string) - response (json or error string) and response status code.

  mbo_update_record(tableName, tableID, parameters, verbose=False)

    Update specific record in a table in Maximo.

    Parameters

      - tableName – (`string`) - Maximo table name

      - tableID – (`int`) - Primary key record ID to update

      - parameters – (`dict`) - Field names (dict keys) and values (dict values) to be updated

      - verbose – (`bool` - optional) - Print internal messages if True (default value False).

    Returns

      (`tuple` - dict or string, string) - response (json or error string) and response status code.

  mxapi_get_request(url)

    Execute get request.

    Parameters

      url – (`string`) - URL to be executed in the get request.

    Returns

      (`requests.response`)

  mxapi_post_request(url, body=None, headers=None)

    Execute get request.

    Parameters

      - url – (`string`) - URL to be executed in the post request.

      - body – (`dict` - optional) - Body to be included in the POST request (default value None).

      - headers – (`dict` - optional) - Additional headers to be added in the POST request (default value None).

    Returns

      (`requests.response`)

  oslc_create_new_record(tableName, parameters, verbose=False)

    Create a new record in a specific table in Maximo.

    Parameters

      - tableName – (`string`) - Maximo table name

      - parameters – (`dict`) - Field names (dict keys) and values (dict values) to be inserted

      - verbose – (`bool` - optional) - Print internal messages if True (default value False).

    Returns

      (`tuple` - dict or string, string) - response (json or error string) and response status code.

  oslc_get_table(tableName, pageSize=None, select=None, where=None, orderBy=None, pageNum=1, stablePaging=False, gbcols=None, verbose=False, current_attempt=1)

    Get data from a specific table in Maximo using OSLC Integration.

    Parameters

      - tableName – (`string`) - Maximo table name to extract data

      - pageSize – (`int` - optional) - Page size for response (default value None). When default is used the default Maximo page size will be used (1000).

      - select – (`string` - optional) - Maximo table fields to be included in the select query (default value None).

      - where – (`string` - optional) - Where condition to filter data (default value None). See https://www.ibm.com/docs/en/mam/7.6.0?topic=orq-query-where-clause-parameter

      - orderBy – (`string` - optional) - Field(s) to order data (default value None). + sign indicated ascending and - sign indicates descending

      - pageNum – (`int` - optional) - Page number in the response (default value 1). Recommended to leave default.

      - stablePaging – (`bool` - optional) - Use Maximo stable paging option (default value False). Recommended to leave default.

      - gbcols – (`string` - optional) - Group by columns condition to aggregate data (default value None). See https://www.imwuc.org/HigherLogic/System/DownloadDocumentFile.ashx?DocumentFileKey=f29fb7ba-5917-f2a9-e599-9161e5d14582

      - verbose – (`bool` - optional) - Print internal messages if True (default value False).

      - current_attempt – (`int` - don’t use) - This argument is intended for internal method use only.

    Returns

      (`tuple` - dict or string, string) - response (json or error string) and response status code.

  oslc_update_record(tableName, restID, parameters, use_oslc=True, verbose=False)

    Update specific record in a table in Maximo

    Parameters

      - tableName – (`string`) - Maximo table name

      - restID – (`int`) - REST ID for the record to be updated

      - parameters – (`dict`) - Field names (dict keys) and values (dict values) to be updated

      - use_oslc – (`bool` - optional) - If True, url will use oslc. If False, url will use rest (default value True)

      - verbose – (`bool` - optional) - Print internal messages if True (default value False)

    Returns

      (`tuple` - dict or string, string) - response (json or error string) and response status code

  validate_and_return_response(response, message, raw=False, content=False)

    Validate response by comparing it against the acceptable status codes. Returns response and status code.

    Parameters

      - response – (`requests.response`) - The response from the query.

      - message – (`string` - optional) - Desired custom error message.

      - raw – (`bool` - optional) - Defines whether to return response raw format or json (default value False).

      - content – (`bool` - optional) - Defines whether to return response content or json (default value False).

    Returns

      (`tuple` - dict or string, string) - response (json, raw or error string) and response status code.