tencent cloud

文档反馈

SubmitJob

最后更新时间:2022-02-23 15:31:57

1. API Description

Domain name for API request: batch.tencentcloudapi.com.

This API is used to submit a instance.

A maximum of 7 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
This document describes the parameters for Signature V1. It's recommended to use the V3 signature, which provides higher security. Note that for Signature V3, the common parameters need to be placed in the HTTP Header. See details.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: SubmitJob.
Version Yes String Common parameter. The value used for this API: 2017-03-12.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
Placement Yes Placement Location information of the submitted job. This parameter allows you to specify information such as the availability zone of the CVM instance with which the job is associated.
Job Yes Job Job information
ClientToken No String The string used to guarantee the idempotency of the request, which is generated by the user and must be unique for different requests. The maximum length is 64 ASCII characters. If this parameter is not specified, the idempotency of the request cannot be guaranteed.

3. Output Parameters

Parameter Name Type Description
JobId String When a job is submitted through this API, this parameter is returned and indicates the job ID. Returning the list of job IDs does not mean that the job is parsed/executed successfully. The job state can be queried using the DescribeJob API.
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Submitting a job

Input Example

https://batch.tencentcloudapi.com/?Action=SubmitJob
&Placement.Zone=ap-guangzhou-2
&Job.JobName=test
&Job.JobDescription=test
&Job.Priority=1
&Job.Tasks.0.TaskName=hello2
&Job.Tasks.0.TaskInstanceNum=1
&Job.Tasks.0.Application.DeliveryForm=LOCAL
&Job.Tasks.0.Application.Command=python -c "fib=lambda n:1 if n<=2 else fib(n-1)+fib(n-2); print(fib(20))"
&Job.Tasks.0.ComputeEnv.EnvType=MANAGED
&Job.Tasks.0.ComputeEnv.EnvData.InstanceType=S1.SMALL1
&Job.Tasks.0.ComputeEnv.EnvData.ImageId=img-bd78fy2t
&Job.Tasks.0.RedirectInfo.StdoutRedirectPath=cos://dondonbatch-1251783334.cosgz.myqcloud.com/hello2/logs/
&Job.Tasks.0.RedirectInfo.StderrRedirectPath=cos://dondonbatch-1251783334.cosgz.myqcloud.com/hello2/logs/
&<Common request parameters>

Output Example

{
  "Response": {
    "JobId": "job-4yn0we13",
    "RequestId": "bf2a9734-e485-423f-9d73-a93f5e6c6a0c"
  }
}

Example2 Submitting a DAG-type job containing dependencies

Input Example

https://batch.tencentcloudapi.com/?Action=SubmitJob
&Placement.Zone=ap-beijing-2
&Job.JobName=dag
&Job.JobDescription=dag_demo
&Job.Tasks.0.TaskName=pre_task
&Job.Tasks.0.TaskInstanceNum=1
&Job.Tasks.0.Application.DeliveryForm=LOCAL
&Job.Tasks.0.Application.Command=echo pre_task
&Job.Tasks.0.ComputeEnv.EnvData.InstanceType=S2.SMALL1
&Job.Tasks.0.RedirectInfo.StdoutRedirectPath=cos://batch-demo-1251783334.cosbj.myqcloud.com/logs/
&Job.Tasks.0.RedirectInfo.StderrRedirectPath=cos://batch-demo-1251783334.cosbj.myqcloud.com/logs/
&Job.Tasks.1.TaskName=post_task
&Job.Tasks.1.TaskInstanceNum=1
&Job.Tasks.1.Application.DeliveryForm=LOCAL
&Job.Tasks.1.Application.Command=echo post_task
&Job.Tasks.1.ComputeEnv.EnvData.InstanceType=S2.SMALL1
&Job.Tasks.1.RedirectInfo.StdoutRedirectPath=cos://batch-demo-1251783334.cosbj.myqcloud.com/logs/
&Job.Tasks.1.RedirectInfo.StderrRedirectPath=cos://batch-demo-1251783334.cosbj.myqcloud.com/logs/
&Job.Dependences.0.StartTask=pre_task
&Job.Dependences.0.EndTask=post_task
&<Common request parameters>

Output Example

{
  "Response": {
    "JobId": "job-2bmv4p7o",
    "RequestId": "165dc518-52a4-4363-8ea4-14f1ee8dea1a"
  }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
AllowedOneAttributeInEnvIdAndComputeEnv One (and only one) parameter must be specified for ComputeEnv and EnvId.
InternalError Internal error.
InternalError.CallCvm An error is returned for the CVM API call.
InternalError.CallTagAPI Error while obtaining the Tag component.
InvalidParameter.CvmParameters Invalid CVM parameter.
InvalidParameter.EnvIdMalformed Invalid compute environment ID format.
InvalidParameter.ImageIdMalformed Incorrect image ID.
InvalidParameter.InvalidParameterCombination Invalid parameter combination.
InvalidParameter.JobDescriptionTooLong The instance description is too long.
InvalidParameter.JobNameTooLong The instance name is too long.
InvalidParameter.NotificationEventNameDuplicate Duplicate message notification event name.
InvalidParameter.NotificationTopicName Invalid topic name.
InvalidParameter.NotificationTopicNameTooLong The topic name is too long.
InvalidParameter.TaskName Invalid job name.
InvalidParameter.TaskNameTooLong The task name is too long.
InvalidParameterValue.ComputeEnv Compute environment parameter validation failed.
InvalidParameterValue.DependenceNotFoundTaskName The dependent task definition was not found.
InvalidParameterValue.DependenceUnfeasible Loop task dependency is prohibited.
InvalidParameterValue.InstanceTypeDuplicate The instance type value must be unique.
InvalidParameterValue.LimitExceeded The number of filter parameter values exceeds the limit.
InvalidParameterValue.LocalPath Invalid local storage path.
InvalidParameterValue.MaxRetryCount The number of retries is too large.
InvalidParameterValue.Negative Invalid negative parameter.
InvalidParameterValue.NotFloat The parameter value is not in float type.
InvalidParameterValue.RemoteStoragePath Invalid storage path format.
InvalidParameterValue.RemoteStorageSchemeType Invalid storage type.
InvalidZone.MismatchRegion The specified zone does not exist.
LimitExceeded.JobQuota Insufficient instance quota.
ResourceNotFound.ComputeEnv The specified compute environment does not exist.
UnauthorizedOperation.UserNotAllowedToUseBatch It is prohibited to use the BatchCompute service.
联系我们

联系我们,为您的业务提供专属服务。

技术支持

如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

7x24 电话支持