File tree 3 files changed +73
-0
lines changed
3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,53 @@ class Job extends Operation {
134
134
let location : string ;
135
135
136
136
const methods = {
137
+ /**
138
+ * @callback DeleteJobCallback
139
+ * @param {?Error } err Request error, if any.
140
+ * @param {object } apiResponse The full API response.
141
+ */
142
+ /**
143
+ * @typedef {array } DeleteJobResponse
144
+ * @property {object } 0 The full API response.
145
+ */
146
+ /**
147
+ * Delete the job.
148
+ *
149
+ * @see [Jobs: delete API Documentation]{@link https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/delete}
150
+ *
151
+ * @method Job#delete
152
+ * @param {DeleteJobCallback } [callback] The callback function.
153
+ * @param {?error } callback.err An error returned while making this
154
+ * request.
155
+ * @param {object } callback.apiResponse The full API response.
156
+ * @returns {Promise<DeleteJobResponse> }
157
+ *
158
+ * @example
159
+ * const {BigQuery} = require('@google-cloud/bigquery');
160
+ * const bigquery = new BigQuery();
161
+ *
162
+ * const job = bigquery.job(jobId);
163
+ * job.delete((err, apiResponse) => {
164
+ * if (!err) {
165
+ * // The job was deleted successfully.
166
+ * }
167
+ * });
168
+ *
169
+ * @example If the callback is omitted a Promise will be returned
170
+ * const [apiResponse] = await job.delete();
171
+ */
172
+ delete : {
173
+ reqOpts : {
174
+ method : 'DELETE' ,
175
+ uri : '/delete' ,
176
+ qs : {
177
+ get location ( ) {
178
+ return location ;
179
+ } ,
180
+ } ,
181
+ } ,
182
+ } ,
183
+
137
184
/**
138
185
* @callback JobExistsCallback
139
186
* @param {?Error } err Request error, if any.
Original file line number Diff line number Diff line change @@ -646,6 +646,25 @@ describe('BigQuery', () => {
646
646
} ) ;
647
647
} ) ;
648
648
649
+ describe ( 'BigQuery/Job' , ( ) => {
650
+ it ( 'should delete a job' , async ( ) => {
651
+ const opts = {
652
+ configuration : {
653
+ query : {
654
+ query : 'SELECT 100 as foo' ,
655
+ } ,
656
+ } ,
657
+ location : 'us-east1' ,
658
+ } ;
659
+
660
+ const [ job ] = await bigquery . createJob ( opts ) ;
661
+ const [ resp ] = await job . delete ( ) ;
662
+ const [ exists ] = await job . exists ( ) ;
663
+ assert . deepStrictEqual ( resp , { } ) ;
664
+ assert . strictEqual ( exists , false ) ;
665
+ } ) ;
666
+ } ) ;
667
+
649
668
describe ( 'BigQuery/Model' , ( ) => {
650
669
let model : Model ;
651
670
const bucket = storage . bucket ( generateName ( 'bucket' ) ) ;
Original file line number Diff line number Diff line change @@ -123,6 +123,13 @@ describe('BigQuery/Job', () => {
123
123
assert . strictEqual ( calledWith . baseUrl , '/jobs' ) ;
124
124
assert . strictEqual ( calledWith . id , JOB_ID ) ;
125
125
assert . deepStrictEqual ( calledWith . methods , {
126
+ delete : {
127
+ reqOpts : {
128
+ method : 'DELETE' ,
129
+ uri : '/delete' ,
130
+ qs : { location : undefined } ,
131
+ } ,
132
+ } ,
126
133
exists : true ,
127
134
get : true ,
128
135
getMetadata : {
You can’t perform that action at this time.
0 commit comments