Skip to content

Commit 88f785e

Browse files
committed
fix: restore cancel-custom-job.js
1 parent d70fefa commit 88f785e

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
async function main(customJobId, project, location = 'us-central1') {
20+
// [START aiplatform_cancel_custom_job_sample]
21+
/**
22+
* TODO(developer): Uncomment these variables before running the sample.\
23+
*/
24+
25+
// const customJobId = 'YOUR_CUSTOM_JOB_ID';
26+
// const project = 'YOUR_PROJECT_ID';
27+
// const location = 'YOUR_PROJECT_LOCATION';
28+
29+
// Imports the Google Cloud Job Service Client library
30+
const {JobServiceClient} = require('@google-cloud/aiplatform');
31+
32+
// Specifies the location of the api endpoint
33+
const clientOptions = {
34+
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
35+
};
36+
37+
// Instantiates a client
38+
const jobServiceClient = new JobServiceClient(clientOptions);
39+
40+
async function cancelCustomJob() {
41+
// Configure the name resource
42+
const name = jobServiceClient.customJobPath(project, location, customJobId);
43+
const request = {
44+
name,
45+
};
46+
47+
// Cancel custom job request
48+
const [response] = await jobServiceClient.cancelCustomJob(request);
49+
50+
console.log('Cancel custom job response:\n', response);
51+
}
52+
cancelCustomJob();
53+
// [END aiplatform_cancel_custom_job_sample]
54+
}
55+
56+
process.on('unhandledRejection', err => {
57+
console.error(err.message);
58+
process.exitCode = 1;
59+
});
60+
61+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)