def create_payload_for_firmware_update(job_type_id: int, baseline_identifier: str,
                                       catalog_identifier: str, repository_id: str, target_data: list,
                                       stage_update: bool):
    """
    Generate the payload to initiate a firmware update job

    Args:
        job_type_id: ID of the job with name 'Update_Task'. This must be a variable because while it is unlikely to
                     change inside of OME, it could. So we look it up every time the script runs.
        baseline_identifier: ID of the baseline which we will update against
        catalog_identifier: ID of the catalog which we will update against
        repository_id: ID of the repository which we will update against
        target_data: A list of dictionaries containing the information required to tell OME what nodes
                     (servers/chassis) to update and the specific devices on those nodes
        stage_update: A boolean indicating whether you would like to stage the updates or deploy them now

    Returns: A dictionary representing the firmware update payload

    """

    if stage_update:
        stage_update_string = "true"
    else:
        stage_update_string = "false"

    return {
        "JobName": "Update Firmware-Test:" + baseline_identifier,
        "JobDescription": "Firmware Update Job",
        "Schedule": "startNow",
        "State": "Enabled",
        "JobType": {
            "Id": job_type_id,
            "Name": "Update_Task"
        },
        "Params": [{
            "Key": "complianceReportId",
            "Value": baseline_identifier
        }, {
            "Key": "repositoryId",
            "Value": repository_id
        }, {
            "Key": "catalogId",
            "Value": catalog_identifier
        }, {
            "Key": "operationName",
            "Value": "INSTALL_FIRMWARE"
        }, {
            "Key": "complianceUpdate",
            "Value": "true"
        }, {
            "Key": "signVerify",
            "Value": "true"
        }, {
            "Key": "stagingValue",
            "Value": stage_update_string
        }],
        "Targets": target_data
    }