Creating a Job Report Using REST API
Learn how to create a migration job report using the DryvIQ REST API.
Table of Contents
Creating a Job With Category
A category for your job is defined outside the transfer block in your JSON, in the section for schedule or job stop policy. The category name is a user-defined string. Any unique string will be recognized as a new category, and the job_category_id will be generated.
},
"schedule": {
"mode": "manual"
},
"stop_policy": {
"on_success": 2
},
"category": {
"name": "Test Category"
}
Example JSON
{
"name":"Job Report | Migration Group 1",
"kind": "transfer",
"transfer": {
"transfer_type": "copy",
"tags": "add",
"source": {
"connection": { "id": "{{cloud_connection_source}}" },
"target": {
"path": "/Source Path"
}
},
"destination": {
"connection": { "id": "{{cloud_connection_destination}}" },
"target": {
"path": "/Destination Path"
}
}
},
"schedule": {
"mode": "manual"
},
"stop_policy": {
"on_success": 2
},
"category": {
"name": "Job Reports - Migration Group 1"
}
}
Adding a Job to an Existing Report
To add a job to an existing report, modify your job JSON to include the job category ID rather than the name. Identify your job category ID by listing all existing reports. Find the report you want your job to be added to and note the the category ID from this report.
GET {{url}}v1/reports
List all Existing Reports Example JSON
....
"type": "reports",
"reports": [
{
"id": "4d804a381c414ad39e816245196414f4",
"name": "Job Reports - Migration Group 1",
"description": "This is my report",
"parameters": {
"job_category_id": 2
},
....
Add Job to Existing Report Example JSON
{
"name":"Create New Job, Add to existing Report",
"kind": "transfer",
"transfer": {
"transfer_type": "copy",
"batch_mode": "always",
"timestamps": "true",
"permissions": "add",
"segment_transform": true,
"duplicate_names": "rename",
"empty_containers": "create",
"versioning": {
"preserve": "native",
"select": "all"
},
"source": {
"connection": { "id": "{{cloud_connection_source}}" },
"target": {
"path": "/SourcePath"
}
},
"destination": {
"connection": { "id": "{{cloud_connection_destination}}" },
"target": {
"path": "/DestinationPath"
}
}
},
"schedule": {
"mode": "manual"
},
"stop_policy": {
"on_success": 2
},
"category": {
"id": 2
}
}
List all Existing Reports Response for Manually Defined List of Jobs
If the report was created with a manual list of jobs, it can be updated to include the new job or jobs to add to the report.
....
"type": "reports",
"reports": [
{
"id": "4d804a381c414ad39e816245196414f4",
"name": "Job Reports - Migration Group 1",
"description": "This is my report",
"parameters": {
"simulation_mode": 0,
"jobs": [
"ade0a8c33e71409bad17ecd92678a458",
"b7648a5d23a941a3bce5d018113d6243"
]
},
....
A job can be added to this report by submitting a PATCH request for this report ID. For example, the following request will add the job with ID 87c53b88142940cf88a35a7e78b8db60 to the report above.
PATCH {{url}}v1/reports/4d804a381c414ad39e816245196414f4
{
"id": "4d804a381c414ad39e816245196414f4",
"parameters": {
"simulation_mode": 0,
"jobs": [
"ade0a8c33e71409bad17ecd92678a458",
"b7648a5d23a941a3bce5d018113d6243",
"87c53b88142940cf88a35a7e78b8db60"
]
}
}
Getting a Job Category ID
In order to create a new report, you will need to get the job category ID.
Get Current Job's Category ID
GET {{url}}v1/jobs/{{job}}?fields=category
List all Job Category IDs
GET {{url}}v1/jobs?fields=category
Jobs that were created without a category fall into the Default category. The default category ID is -1.
Creating a New Report
To create a new report, you must use the job_category_id. The category string name will not be accepted.
POST {{url}}v1/reports
{
"name": "Report 1",
"created_by": "Joe Smith",
"description": "This is my report",
"parameters": {
"job_category_id": 2
}
}
Creating a New Report for Simulation Jobs
To create a new report for simulation / analyzer jobs, you must use the corresponding job_category_id as well as simulation_mode:true parameter.
POST {{url}}v1/reports
{
"name": "Simulation Jobs",
"created_by": "Joe Smith",
"description": "This is my Analyzer Job report",
"parameters": {
"job_category_id": 2,
"simulation_mode": true
}
}
Listing Reports
List all Reports
GET {{url}}v1/reports
List Report by ID
GET {{url}}v1/reports/{{report_id}}?include=all
Report Stats and Transfer Items
Get Transfer Items for Report by ID
GET {{url}}v1/reports/{{report_id}}/items
Get transfer stats for Report by ID
GET {{url}}v1/reports/{{report_id}}/stats