def create_job()

in src/api/app.py [0:0]


def create_job(event, body, job_id):
    bucket_name = body["bucket"]
    object_key = body["key"]
    client_tag = body["client_tag"]
    tier = body["tier"]
    expiration_days = body["expiration_days"]

    s3_result = s3_client.head_object(Bucket=bucket_name, Key=object_key)
    object_etag = s3_result["ETag"]

    response = s3_control_client.create_job(
        AccountId=account_id,
        ConfirmationRequired=False,
        ClientRequestToken=job_id,
        Manifest={
            "Spec": {
                "Format": "S3BatchOperations_CSV_20180820",
                "Fields": ["Bucket", "Key"]
            },
            "Location": {
                "ObjectArn": f"arn:aws:s3:::{bucket_name}/{object_key}",
                "ETag": object_etag
            }
        },
        Operation={
            "S3InitiateRestoreObject": {
                "ExpirationInDays": expiration_days,
                "GlacierJobTier": tier
            }
        },
        Report={
            "Bucket": REPORT_BUCKET,
            "Format": 'Report_CSV_20180820',
            "Enabled": True,
            "ReportScope": "AllTasks"
        },
        Priority=10,
        RoleArn=ROLE_ARN,
        Tags=[{"Key": "client_tag", "Value": client_tag}]
    )

    return response