NEXUS IC REST API Class — pynexusic 2.5.0 documentation

# NEXUS IC REST API Class

NEXUS IC REST API class allows the user to communicate with Wood NEXUS IC REST API using python.

Prerequisites:

- Python > 3.7

- NEXUS IC > V6.6

- IC-Web > V6.6

class NEXUSIC_RESTAPI.NEXUSIC_REST(icweb_uri, authentication_type='APIKEY', username=None, password=None, api_key=None, max_attempts=1, timeout=None, verbose=False, verify=True, logger=None)
  Parameters

    - icweb_uri – (`string`) - IC-Web URL.

    - authentication_type –

      (`string` - optional) - This can be one of the following values (default value APIKEY).

          ['APIKEY', 'BASIC']

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

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

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

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

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

    - 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

  addGraphAsset(fullLocation, cvID=None, pageSize=None, verbose=False)

    Add an AssetNode to the built-in graph.

    Parameters

      - fullLocation – (`string`) - Full location is specified the same way it is defined in a typical NEXUS import sheet (single column)

      - cvID – (`int`) - Asset View ID.

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

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

    Returns

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

  addParamToURI(uri, param, value)
  authenticate(verbose=False)

    Authenticate with NEXUS IC using the defined authentication type used in the class constructor. For more details see https://docs.nexusic.com/6.6/ic-web.rest.security.login.html#ic-web-rest-security-login

    Parameters

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

    Returns

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

  createLinkedAssets(assets, pageSize=None, verbose=False)

    Creates Linked Assets with or without children.

    If the parent asset link location already exists and linked children is Yes, then the function will skip or miss the parent asset link and add the child asset links.

    Parameters

      - assets –

        (`list`)

            assets = [{'asset_full_location': 'xxxx / xxxx',
                        'asset_view': 'xxxx',
                        'link_full_location': 'xxxx / xxxx',
                        'link_view': 'xxxx',
                        'link_with_children': True}]

        where:

        - asset_full_location: Source asset full location. Follows the same format as the standard NEXUS import sheet (single column)

        - asset_view: Source Asset view name. If provided asset view does not exist, then first entry in the Comp_View table will be used

        - link_full_location: Destination asset full location. Follows the same format as the standard NEXUS import sheet (single column)

        - link_view: Destination Asset view name. If provided asset view does not exist, then first entry in the Comp_View table will be used

        - link_with_children: Boolean value to identify whether to link assets with chidren or not.

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

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

    Returns

      (`tuple` - list, list) - List of linked assets and missed assets.

  createNewAssets(assets, pageSize=None, verbose=False)

    Imports new assets in the NEXUS IC database. This function will create the assets in the Component and View_Node tables.

    Parameters

      - assets –

        (`list`) - Assets to be imported. Must follow the following format:

            assets = [{'asset_full_location': 'xxxx / xxxx',
                        'asset_type': 'xxxx',
                        'asset_view': 'xxxx'}]

        where:

        - asset_full_location: Follows the same format as the standard NEXUS import sheet (single column)

        - asset_type: (optional) Asset type name as listed in the NEXUS database. If omitted then asset type will be blank

        - asset_view: Asset view name. If provided asset view does not exist, then first entry in the Comp_View table will be used

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

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

    Returns

      (`tuple` - list, list) - List of imported assets and missed assets.

  createNewEvents(events, sameAsset=False, sameWorkpack=False, sameEventType=False, sameSurveySet=False, pageSize=None, verbose=False)

    Imports new events in the NEXUS IC database. This function creates new event and doesn’t update existing events

    Parameters

      - events –

        (`list`) - Events to be imported. Must follow the following format:

            events = [{'component_id': xxxx,
                        'asset_full_location': 'xxxx / xxxx',
                        'event_type': 'xxxx',
                        'workpack_name': 'xxxx',
                        'survey_set': 'xxxx',
                        'start_clock': 'YYYY-MM-DDThh:mm:ss.ssssZ',
                        'end_clock': 'YYYY-MM-DDThh:mm:ss.ssssZ',
                        'comment': 'xxxxx',
                        'fields': {'<Field Name 1>': xxx,
                                    '<Field Name 2>': xxx,
                                    '<Field Name 3>': xxx
                                    },
                        'multimedia': [{'name': 'xxxx',
                                        'filename': 'xxxx/xxxx',
                                        'binary_data': b'xxxx'}
                                      ]
                        }
                    ]

        where:

        - component_id: Optional if asset_full_location is provided - Using component_id provides better performance

        - asset_full_location: Optional if component_id is provided - Follows the same format as the standard NEXUS import sheet (single column)

        - survey_set: Optional (default value is Raw Survey Data)

        - start_clock and end_clock: YYYY for years, MM for months, DD for days, hh for hours, mm for minutes, ss for seconds and .ssss for milliseconds

        - fields: NEXUS field names are the keys (as shown in NEXUS IC)

        - multimedia: Optional - List of multimedia to be imported with each event

      - sameAsset – (`bool` - optional) - Used when all events have the same asset.

      - sameWorkpack – (`bool` - optional) - Used when all events have the same workpack.

      - sameEventType – (`bool` - optional) - Used when all events have the same event type.

      - sameSurveySet – (`bool` - optional) - Used when all events have the same survey set.

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

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

    Returns

      (`tuple` - list, list) - List of imported events and missed events.

  createNewRecord(tableDBName, body, key_value=0, current_attempt=1, verbose=False)
  deleteRecord(tableDBName, keyValue, current_attempt=1, verbose=False)
  execFunction(functionName, parameters=None, current_attempt=1, verbose=False)
  execUpdate(tableDBName, tableID, body, current_attempt=1, verbose=False)
  generateReport(report_name, recipient, format='XLSX', current_attempt=1, verbose=False)
  generateReport_v2(report_name=None, report_id=None, format='XLSX', parameters=None, current_attempt=1, verbose=False)

    Generate a report from Report_Template table using RT_ID.

    Parameters

      - report_name – (`string` - optional) - Name of report as it appears in NEXUS (default value None).

      - report_id – (`string` - optional) - RT_ID value for the report (default value None). When default is used the RT_ID will be determined from report_name.

      - format – (`string` - optional) - Format of document to be generated (default value XLSX). json, html, xlsx, rtf are accepted types.

      - parameters – (`tuple` - optional) - Report parameters in a json-formatted dict (default value None).

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

      - verbose – (`bool` - optional) - Show more details in command line output (default value False).

    Returns

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

  generate_base64(value)

    Generate base64 string

    Parameters

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

    Returns

      (`String`) - base64 string.

  generate_hash(verbose=False)

    Generate hash key to be used in the REST calls

    Parameters

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

    Returns

      (`string`) - Hash key

  getAssetByFullLocation(fullLocation, assetView=None, pageSize=None, verbose=False)

    Get Asset details from View_Node table using full location.

    Parameters

      - fullLocation – (`string`) - Full location is specified the same way it is defined in a typical NEXUS import sheet (single column).

      - assetView – (`string` - optional) - Asset view name (default value None).

      - compID – (`int` - optional) - Asset Component ID (default value None). This parameter is used to overcome multiple assets having the same location.

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

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

    Returns

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

  getAssetChildren(assetLocation, assetView=None, searchType='MAX LEVEL', assetTypes=None, maxLevel=- 1, atLevel=- 1, pageSize=None, verbose=False)
  getAssetLocationByID(assetID, assetView, pageSize=None, verbose=False)
  getAssetLocationByName(assetName, assetView, pageSize=None, verbose=False)
  getAssetTypesID(assetTypes, pageSize=None, verbose=False)
  getDashboard(dashboard_Name, current_attempt=1, verbose=False)
  getLookupListItem(LI_ID, lookupListName=None, verbose=False)

    Gets lookup item information given a lookup item ID. The lookup list name can be passed as parameter.

    Parameters

      - LI_ID – (`int`) - Lookup item ID in the database.

      - lookupListName – (`string` - optional) - Lookup list name hosting the lookup item (default value None).

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

    Returns

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

  getMultimedia(rd_id, current_attempt=1, verbose=False)
  getTable(tableDBName, xFilter=None, pageSize=None, current_attempt=1, verbose=False)

    Execute GET REST call to get data from specific table

    Parameters

      - tableDBName – (`string`) - Table name as specified in the database (not the NEXUS IC display table name).

      - xFilter – ( `dict` in `JSON` fomrat - optional) - Used to filter data from the required table (default value None).

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

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

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

    Returns

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

  getTableDBNames(tableNames, tableType, pageSize=None, verbose=False)
  getTableDefInfo(tableName, tableType, pageSize=None, verbose=False)
  getVersion(current_attempt=1, verbose=False)
  get_rt_id(report_name, verbose=False)

    Gets the RT_ID value from the Report_Template table using a report’s Name :param report_name: (`string`) - Name of the Report as it appears in NEXUS :param verbose: (`bool` - optional) - Print internal messages if True (default value False)

    Returns

      (`int`) - RT_ID value

  importLibrary(library_type, l_name, filename, binary_data, ref_date=None, document_no=None, revision=None, description=None, location=None, hyperlink=None, show_grayscale=False, show_caption=True, show_dimensions=True, can_report=True, force_2d=False, background_color=None, verbose=False)

    Import library item

    Parameters

      - library_type – (`string`) - Library type name

      - l_name – (`string`) - Library item name

      - filename – (`string`) - Name of the file to be imported

      - binary_data – (`byte`) - The actual file as a byte variable

      - ref_date – (`datetime` - optional) - Library item reference date (default value None)

      - document_no – (`string` - optional) - Library item document number (default value None)

      - revision – (`string` - optional) - Library item revision (default value None)

      - description – (`string` - optional) - Library item description (default value None)

      - location – (`string` - optional) - Library item physical location path (default value None)

      - hyperlink – (`string` - optional) - Library item hyperlink (default value None)

      - show_grayscale – (`bool` - optional) - Show library as grayscale (default value False)

      - show_caption – (`bool` - optional) - Show library captions (default value True)

      - show_dimensions – (`bool` - optional) - Show library dimensions (default value True)

      - can_report – (`bool` - optional) - Show library in reports (default value True)

      - force_2d – (`bool` - optional) - Used only for Autocad files (default value False)

      - background_color – (`int` - optional) - Background color (default value None)

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

    Returns

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

  importMultimedia(header_id, mm_name, filename, binary_data, is_image=True, verbose=False)

    Import multimedia and attach it to a specific event

    Parameters

      - header_id – (`int`) - Event header ID where the multimedia will be linked to

      - mm_name – (`string`) - Multimedia name displayed in NEXUS IC

      - filename – (`string`) - Name of the file to be imported

      - binary_data – (`byte`) - The actual file as a byte variable

      - is_image – (`bool` - optional) - Define whether the file is an image or AVI file (default value True)

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

    Returns

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

  importRepository(filename, binary_data, verbose=False)

    This call import external documentation in the database to be used with other modules within NEXUS IC

    Parameters

      - filename – (`string`) - Name of the file to be imported

      - binary_data – (`byte`) - The actual file as a byte variable

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

    Returns

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

  jobContent(job_id, current_attempt=1, verbose=False)

    Get the Job Content of a job via its job ID.

    Parameters

      - job_id – (`int`) - Unique job ID provided in server response.

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

      - verbose – (`bool` - optional) - Show more details in command line output (default value False).

    Returns

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

  jobStatus(job_id, current_attempt=1, verbose=False)

    Get the Job Status of a job via its job ID.

    Parameters

      - job_id – (`string`) - Unique job ID provided in server response.

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

      - verbose – (`bool` - optional) - Show more details in command line output (default value False).

    Returns

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

  validate_and_return_response(response, message, raw=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).

    Returns

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