create-job
The create-job command creates a batch job that performs a specified operation on a large number of objects.
Usage notes
By default, an Alibaba Cloud account has the permissions to create a batch job. To perform this operation by using a RAM user or Security Token Service (STS), you must have the oss:CreateJob permission. For more information, see Grant a custom policy.
-
Operationcan contain only one operation type. -
ManifestandKeyPrefixManifestGenerator: specify only one of them. The former uses an existing manifest file, and the latter generates a manifest based on a prefix. -
The bucket that stores the report and the bucket that stores the manifest file must reside in the same region as the batch job.
Command syntax
ossutil api create-job --create-job-request value
|
Parameter |
Type |
Description |
|
--create-job-request |
string |
The container that stores the batch job configuration, in XML or JSON format. If the option value contains the |
--create-job-request
The --create-job-request option supports XML and JSON syntax. If the option value contains the file:// prefix, the configuration is read from the specified file. The XML syntax is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<CreateJobRequest>
<ConfirmationRequired>boolean</ConfirmationRequired>
<Operation>
<PutObjectTagging>
<TagSet>
<Tag>
<Key>string</Key>
<Value>string</Value>
</Tag>
</TagSet>
</PutObjectTagging>
<AddObjectTagging>
<TagSet>
<Tag>
<Key>string</Key>
<Value>string</Value>
</Tag>
</TagSet>
</AddObjectTagging>
<DeleteObjectTagging>
</DeleteObjectTagging>
<PutObjectAcl>
<ObjectAcl>string</ObjectAcl>
</PutObjectAcl>
<RestoreObject>
<Days>integer</Days>
<Tier>string</Tier>
</RestoreObject>
</Operation>
<Report>
<Bucket>string</Bucket>
<Enabled>boolean</Enabled>
<Prefix>string</Prefix>
<ReportScope>string</ReportScope>
</Report>
<ClientRequestToken>string</ClientRequestToken>
<Manifest>
<Location>
<ETag>string</ETag>
<Bucket>string</Bucket>
<Object>string</Object>
<VersionId>string</VersionId>
</Location>
<Spec>
<Fields>string</Fields>
<Format>string</Format>
</Spec>
</Manifest>
<KeyPrefixManifestGenerator>
<SourceBucket>string</SourceBucket>
<Prefix>string</Prefix>
</KeyPrefixManifestGenerator>
<Description>string</Description>
<Priority>integer</Priority>
<RoleArn>string</RoleArn>
</CreateJobRequest>
|
Parameter |
Type |
Required |
Description |
|
ConfirmationRequired |
Boolean |
No |
Specifies whether the job requires confirmation before it runs. If this field is set to true, the job enters the Suspended state after it is created, and runs only after you use the update-job-status command to set its status to Ready. |
|
Operation |
Container |
Yes |
The operation that the batch job performs. The container can contain only one operation. Supported operations: PutObjectTagging, AddObjectTagging, DeleteObjectTagging, PutObjectAcl, and RestoreObject. |
|
Operation.PutObjectTagging.TagSet.Tag.Key |
String |
Yes (if PutObjectTagging is used) |
The tag key. |
|
Operation.PutObjectTagging.TagSet.Tag.Value |
String |
Yes (if PutObjectTagging is used) |
The tag value. |
|
Operation.PutObjectAcl.ObjectAcl |
String |
Yes (if PutObjectAcl is used) |
The ACL of the object. Valid values: default, private, public-read, and public-read-write. |
|
Operation.RestoreObject.Days |
Integer |
No |
The restoration period of Archive, Cold Archive, or Deep Cold Archive objects. Valid values for Archive objects: 1 to 7. Valid values for Cold Archive and Deep Cold Archive objects: 1 to 365. |
|
Operation.RestoreObject.Tier |
String |
No |
The restoration priority of Cold Archive or Deep Cold Archive objects. Valid values for Cold Archive objects: Standard (2 to 5 hours) and Bulk (5 to 12 hours). Valid value for Deep Cold Archive objects: Standard (within 48 hours). |
|
Report |
Container |
Yes |
The configuration of the job report. |
|
Report.Bucket |
String |
Yes |
The bucket in which the report is stored. The bucket must reside in the same region as the batch job. |
|
Report.Enabled |
Boolean |
Yes |
Specifies whether to generate a report. |
|
Report.Prefix |
String |
No |
The prefix of the report, which stores the report in the specified directory. |
|
Report.ReportScope |
String |
No |
The scope of the report. Valid values: AllTasks (reports all tasks) and FailedTasksOnly (reports only failed tasks). Default value: AllTasks. |
|
ClientRequestToken |
String |
Yes |
The unique identifier that ensures the idempotence of the request. The value must be 1 to 64 characters in length. |
|
Manifest |
Container |
Conditionally required |
The manifest configuration. Specify either Manifest or KeyPrefixManifestGenerator. |
|
Manifest.Location.Bucket |
String |
Yes (if Manifest is used) |
The bucket in which the manifest file is stored. The bucket must reside in the same region as the batch job. |
|
Manifest.Location.Object |
String |
Yes (if Manifest is used) |
The object that corresponds to the manifest file. |
|
Manifest.Location.ETag |
String |
No |
The ETag of the manifest file. |
|
Manifest.Location.VersionId |
String |
No |
The version ID of the object that corresponds to the manifest file. |
|
Manifest.Spec.Format |
String |
Yes (if Manifest is used) |
The format of the manifest. Valid values: OSS_BatchOperations_CSV_20250611 (the CSV format of OSS Batch Operations) and OSS_InventoryReport_CSV_20250611 (the CSV format of an OSS inventory report). |
|
Manifest.Spec.Fields |
String |
No |
The CSV field definition of the manifest. Specify this field if you use a CSV manifest that you upload. |
|
KeyPrefixManifestGenerator |
Container |
Conditionally required |
Generates a manifest based on a prefix. Specify either Manifest or KeyPrefixManifestGenerator. |
|
KeyPrefixManifestGenerator.SourceBucket |
String |
Yes (if KeyPrefixManifestGenerator is used) |
The source bucket of the manifest. |
|
KeyPrefixManifestGenerator.Prefix |
String |
No |
The prefix of the objects, which is used to filter the objects to process. |
|
Description |
String |
No |
The description of the job. |
|
Priority |
Integer |
Yes |
The priority of the job. A larger value indicates a higher priority. |
|
RoleArn |
String |
Yes |
The ARN of the RAM role that OSS assumes to run the batch job. |
-
This command requires ossutil 2.4.1 or later.
-
For more information about the supported global command-line options, see Global command-line options.
Usage examples
Generate a manifest based on a prefix and add tags to all objects with the data/ prefix in examplebucket. The following example shows the content of the create-job-request.json file:
{
"Operation": {
"PutObjectTagging": {
"TagSet": {
"Tag": [
{
"Key": "Environment",
"Value": "Production"
}
]
}
}
},
"Report": {
"Bucket": "report-bucket",
"Enabled": true,
"Prefix": "reports/",
"ReportScope": "AllTasks"
},
"ClientRequestToken": "unique-token-123",
"KeyPrefixManifestGenerator": {
"SourceBucket": "examplebucket",
"Prefix": "data/"
},
"Description": "batch put object tagging",
"Priority": 10,
"RoleArn": "acs:ram::123456789012****:role/BatchOperationRole"
}ossutil api create-job --create-job-request file://create-job-request.json
Create a job that restores archived objects based on an existing manifest file. The following example shows the content of the create-job-request.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<CreateJobRequest>
<Operation>
<RestoreObject>
<Days>7</Days>
<Tier>Standard</Tier>
</RestoreObject>
</Operation>
<Report>
<Bucket>report-bucket</Bucket>
<Enabled>true</Enabled>
</Report>
<ClientRequestToken>unique-token-456</ClientRequestToken>
<Manifest>
<Location>
<Bucket>manifest-bucket</Bucket>
<Object>manifest.csv</Object>
</Location>
<Spec>
<Format>OSS_BatchOperations_CSV_20250611</Format>
</Spec>
</Manifest>
<Description>batch restore archived objects</Description>
<Priority>10</Priority>
<RoleArn>acs:ram::123456789012****:role/BatchOperationRole</RoleArn>
</CreateJobRequest>ossutil api create-job --create-job-request file://create-job-request.xml
Create a job that deletes object tags by passing a JSON string on the command line.
ossutil api create-job --create-job-request '{"Operation":{"DeleteObjectTagging":""},"Report":{"Bucket":"report-bucket","Enabled":true},"ClientRequestToken":"unique-token-789","KeyPrefixManifestGenerator":{"SourceBucket":"examplebucket"},"Description":"batch delete object tagging","Priority":10,"RoleArn":"acs:ram::123456789012****:role/BatchOperationRole"}'