Running data imports

Available from 9.2.2. You can use this REST API to check the status of a data import, or to run a Raw Data Only, or a Complete data import. All these actions are completed through a common API request. You distinguish between them by appending the request with specific parameters. To work with this API, you use the GET operation on the api/import_status.json element, or its alias api/management/imports.json.

Before you begin

An icon representing a user. You must have the Manage Imports permission to perform this task.

Checking the import status

Before you start running data imports, retrieve the status of a data import to ensure that no imports are currently in progress. The statuses that can be retrieved are explained in Example HTTP conversation. To check the import status, use the following request:
https://hostname:port/api/import_status.json?token=token

Running a Raw Data Only import

Running a Raw Data Only import is much quicker, because it only retrieves raw scan results. This type of data import is used for retrieving raw scan results through REST API. A Raw Data Only data import includes the following steps of the import process:

  • Initialization of models:
    Calling Model.before_snapshot
  • Initialization of each data source:
    Initialize datasource #{datasource.name}
  • Computer data:
    RawComputerId
    Computer
    ComputerPropertyValue
    ComputerDimension
  • Computer-related files:
    RawDatasourceFile
    DatasourceFile
    SAM::ScanFile
  • Scanned file, package, UNIX package, and application usage data:
    SAM::FileFactDelta
    SAM::FileFact
    SAM::RawPackageFact
    SAM::PackageFact
    SAM::RawUnixPackageFact
    SAM::UnixPackageFact
    SAM::RawAppUsagePropertyValue
    SAM::AppUsagePropertyValue
To start importing your raw data, append the API request with the run parameter, and specify the value as raw_only:
https://hostname:port/api/import_status.json?token=token&run=raw_only
Note: After running a Raw Data Only data import, the raw data can be retrieved through REST API, but is not visible in the UI. The UI still shows the state of your environment from the last successful data import. The only exception is the Metering Data report that shows the most recent data even after a raw only data import. For more details, see Importing raw scan data

Running a complete data import

Running a Complete import through REST API has the same effect as running the data import from the UI. To start importing your data, append the API request with the run parameter, and specify the value as Complete:
https://hostname:port/api/import_status.json?token=token&run=complete

Operation descriptions

Note: Each API request must be authenticated with the token parameter. You can retrieve it by using REST API for retrieving authentication token. You can also log in to BigFix Inventory, hover over the User icon , and click Profile. Then, click Show token.
Table 1. Operation descriptions

The table consists of two columns and 15 rows. For the eleventh row there are two levels.

Operation details Description
Operation GET /api/import_status.json, or GET /api/management/imports.json
Purpose Returns the status of the data import
HTTP method GET
Resource URI https://server_host_name:port_number/api/import_status.json, or https://server_host_name:port_number/api/management/imports.json
URL link relation n/a
URI query parameters n/a
Request headers
Header
Accept-Language (optional)
Values
en-US (only English is supported)

Used to negotiate the language of the response. If this header is not specified, the content is returned in the server language.

Request payload n/a
Request Content-Type
  • application/json
Response headers
Header
Content-Type
Values
application/json

Specifies the content type of the response.

Header
Content-Language
Values
en-US, …;

Specifies the language of the response content. If this header is not specified, the content is returned in the server language.

Response payload Import status element
Response Content-Type
  • application/json
Normal HTTP response codes
  • 200 – OK
Error HTTP response codes
  • 500 – “Bad Request” if a query parameter contains errors or is missing

Message body includes an error message with details.

Query parameters

You can use query parameters to narrow down the results of your search or perform extra actions. The following table presents query parameters that you can use for the api/import_status.json and api/management/imports.json elements.
Table 2. Query parameters for running a data import and retrieving its status

The table consists of four columns and nine rows.

Parameter Description Required Value
format Specifies the format of the retrieved information. The possible values are json or xml.
Retrieve information in the json format:
URL?format=json
No String
token A unique user authentication identifier. You can view your token in the Profile preferences of BigFix InventoryLicense Metric Tool. Yes Alphanumeric
run Specifies the type of a data import to run. The possible values are:
  • complete - runs a Complete data import
  • raw_only - runs a Raw Data Only import that retrieves raw scan results. The data is not aggregated and therefore not shown in the UI. You can only retrieve it through REST API.
No String

Example HTTP conversation

Request
GET api/import_status.json
?token=7adc3efb175e2bc0f4484bdd2efca54a8fa04623
Host: localhost:9081 
Accept: application/json 
Accept-Language: en-US
Response header
HTTP/1.1 200 OK
Content-Type: application/json
Content-Language: en-US
Response body (JSON)
If a data import has never been initiated:
{
  "mode": "none",
  "can_run_imports": true,
  "import_status_url": "/import_status",
  "import_create_url": "/management/imports",
}
If a data import is in progress:
{
  "mode": "running",
  "can_run_imports": true,
  "import_status_url": "/import_status",
  "import_create_url": "/management/imports",
  "progress": 59
}
If a data import is not running:
{
  "mode": "idle"/"pending",
  "can_run_imports": true,
  "import_status_url": "/import_status",
  "import_create_url": "/management/imports",
  "last_status": successful,
  "last_success_time": "2015-06-18T04:00:29Z"
  "last_import_time": "2015-06-18T04:00:29Z",
  "last_import_type": "raw_only"
  "next_import_time": "2015-06-20T06:00:00Z",
  "next_import_time_in": 75057,
  "next_import_type": "complete"
}
Where:
  • mode - status of the data import, it can assume the following values:
    • none - a data import has never been initiated
    • idle - no data imports are currently running
    • running - a data import is in progress
    • pending - an action performed in the user interface requires a data import to be started for the change to take effect
  • can_run_imports - specifies whether the user retrieving this API can run imports,
  • import_status_url - web address of this API,
  • import_create_url - web address of the data imports panel in BigFix InventoryLicense Metric Tool,
  • progress - percentage status of the running import,
  • last_status - status of the last import,
  • last_success_time - time of the last successful import,
  • last_import_time - time of the last import,
  • last_import_type - type of the last import,
  • next_import_time - time of the next scheduled data import,
  • next_import_time_in - remaining time (in seconds) to the next scheduled data import,
  • next_import_type - type of the next scheduled data import.