Retrieve Collection Job Summary

Scenario Overview

Retrieving the collection job summary provides an overview of the operational status of collection jobs in the CNC Collection Service. This information is useful for monitoring, debugging, and validating job performance.

The GetCollectionJobSummary API allows you to track the operational status of requests within the Collection Service. It returns the current job status, which can include the following phases:

  • READY: The job is ready for execution.
  • NOT_READY: The job is not ready to execute.
  • FAILED: The job has failed.
  • TERMINATING: The job is in the process of being terminated.
  • TERMINATION_FAILED: The job termination has failed.

If the current status phase is TERMINATING or TERMINATION_FAILED, you cannot perform create or update operations on the ApplicationContext. In the TERMINATION_FAILED phase, you can attempt to retry the deletion of the Collection Job. Once the Collection Job enters the TERMINATING or TERMINATION_FAILED phase, the operational status of the job is no longer relevant.

Supplying an ApplicationContext is optional when using this API.

The operations in the following API references are used in this example.

Prerequisites

Before running this example, ensure that you have obtained an access token. Refer to the 'Getting Started' section for instructions.

Get Collection Job Summary

To retrieve the summary for a collection job, update the collection_job_summary_query.json input file with the required details (e.g., ApplicationContext or job ID), then run the collection_job_summary_query.sh script from the example directory.

Navigate to the cnc-collections-api-examples directory and run the collection_job_summary_query.sh script using the following command:

cd cnc-collections-api-examples;./collection_job_summary_query.sh

Script Details

#!/bin/bash
# Import common API functions and environment variables
# This script reads input from the .json file located in the input directory.
# Upon successful execution, the output is saved to the .json file in the output directory.
. ./cnc-api-common.sh

collection_job_summary_query() {
    # Step 1: Ensure the CNC JWT is obtained by running the get-cnc-jwt.sh script.
    # Read the JWT from the file and export it as the AUTH_TOKEN_HDR environment variable.
     export_jwt

    # STEP 2 :  Update the input json with details of job for which you want the summary in the file CNC_API_INPUT
    # STEP 3 :  Retrieve summary for collection job from the server and store the output in CNC_API_OUTPUT file

    CNC_COLLECTION_API=$CNC_COLLECTION_API_CTX/collectionjob/summary/query
    CNC_API_INPUT="@$PRJ/input/collection_job_summary_query.json"	 
    CNC_API_OUTPUT="$PRJ/output/collection_job_summary_query.json"

    # Step 4: Send a POST request to retrieve the collection job summary and store the response in the output file.
    http_post $CNC_COLLECTION_API $CNC_API_INPUT $CNC_API_OUTPUT
    
}
collection_job_summary_query