from tencentcloud.common import credentialfrom tencentcloud.common.profile.client_profile import ClientProfilefrom tencentcloud.common.profile.http_profile import HttpProfilefrom tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKExceptionfrom tencentcloud.batch.v20170312 import batch_client, modelstry:cred = credential.Credential("your secret id", "your secret key")httpProfile = HttpProfile()httpProfile.endpoint = "batch.tencentcloudapi.com"clientProfile = ClientProfile()clientProfile.httpProfile = httpProfileclient = batch_client.BatchClient(cred, "ap-guangzhou", clientProfile)req = models.SubmitJobRequest()params = '{"Placement":{"Zone":"ap-guangzhou-3"},"Job":{"JobName":"demo","JobDescription":"test job","Priority":1,"Tasks":[{"TaskName":"task","TaskInstanceNum":1,"Application":{"Command":"echo hello"},"ComputeEnv":{"EnvData":{"InstanceType":"S2.SMALL1","ImageId":"img-enf3kukl","SystemDisk":{"DiskType":"CLOUD_PREMIUM","DiskSize":50}}},"MaxRetryCount":1,"Timeout":3600}]}}'req.from_json_string(params)resp = client.SubmitJob(req)print(resp.to_json_string())except TencentCloudSDKException as err:print(err)
from tencentcloud.common import credentialfrom tencentcloud.common.profile.client_profile import ClientProfilefrom tencentcloud.common.profile.http_profile import HttpProfilefrom tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKExceptionfrom tencentcloud.batch.v20170312 import batch_client, modelstry:cred = credential.Credential("your secret id", "your secret key")httpProfile = HttpProfile()httpProfile.endpoint = "batch.tencentcloudapi.com"clientProfile = ClientProfile()clientProfile.httpProfile = httpProfileclient = batch_client.BatchClient(cred, "ap-guangzhou", clientProfile)req = models.DescribeJobRequest()params = '{"JobId":"job-mhgy1dot"}'req.from_json_string(params)resp = client.DescribeJob(req)print(resp.to_json_string())except TencentCloudSDKException as err:print(err)
import com.tencentcloudapi.common.Credential;import com.tencentcloudapi.common.profile.ClientProfile;import com.tencentcloudapi.common.profile.HttpProfile;import com.tencentcloudapi.common.exception.TencentCloudSDKException;import com.tencentcloudapi.batch.v20170312.BatchClient;import com.tencentcloudapi.batch.v20170312.models.SubmitJobRequest;import com.tencentcloudapi.batch.v20170312.models.SubmitJobResponse;public class SubmitJob{public static void main(String [] args) {try{Credential cred = new Credential("your secret id", "your secret key");HttpProfile httpProfile = new HttpProfile();httpProfile.setEndpoint("batch.tencentcloudapi.com");ClientProfile clientProfile = new ClientProfile();clientProfile.setHttpProfile(httpProfile);BatchClient client = new BatchClient(cred, "ap-guangzhou", clientProfile);String params = "{\\"Placement\\":{\\"Zone\\":\\"ap-guangzhou-3\\"},\\"Job\\":{\\"JobName\\":\\"demo\\",\\"JobDescription\\":\\"test job\\",\\"Priority\\":1,\\"Tasks\\":[{\\"TaskName\\":\\"task\\",\\"TaskInstanceNum\\":1,\\"Application\\":{\\"Command\\":\\"echo hello\\"},\\"ComputeEnv\\":{\\"EnvData\\":{\\"InstanceType\\":\\"S2.SMALL1\\",\\"ImageId\\":\\"img-enf3kukl\\",\\"SystemDisk\\":{\\"DiskType\\":\\"CLOUD_PREMIUM\\",\\"DiskSize\\":50}}},\\"MaxRetryCount\\":1,\\"Timeout\\":3600}]}}";SubmitJobRequest req = SubmitJobRequest.fromJsonString(params, SubmitJobRequest.class);SubmitJobResponse resp = client.SubmitJob(req);System.out.println(SubmitJobRequest.toJsonString(resp));} catch (TencentCloudSDKException e) {System.out.println(e.toString());}}}
import com.tencentcloudapi.common.Credential;import com.tencentcloudapi.common.profile.ClientProfile;import com.tencentcloudapi.common.profile.HttpProfile;import com.tencentcloudapi.common.exception.TencentCloudSDKException;import com.tencentcloudapi.batch.v20170312.BatchClient;import com.tencentcloudapi.batch.v20170312.models.DescribeJobRequest;import com.tencentcloudapi.batch.v20170312.models.DescribeJobResponse;public class DescribeJob{public static void main(String [] args) {try{Credential cred = new Credential("your secret id", "your secret key");HttpProfile httpProfile = new HttpProfile();httpProfile.setEndpoint("batch.tencentcloudapi.com");ClientProfile clientProfile = new ClientProfile();clientProfile.setHttpProfile(httpProfile);BatchClient client = new BatchClient(cred, "ap-guangzhou", clientProfile);String params = "{\\"JobId\\":\\"job-mhgy1dot\\"}";DescribeJobRequest req = DescribeJobRequest.fromJsonString(params, DescribeJobRequest.class);DescribeJobResponse resp = client.DescribeJob(req);System.out.println(DescribeJobRequest.toJsonString(resp));} catch (TencentCloudSDKException e) {System.out.println(e.toString());}}}
本页内容是否解决了您的问题?