|
| 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(datasetId, project, location = 'us-central1') { |
| 20 | + // [START aiplatform_delete_dataset_sample] |
| 21 | + /** |
| 22 | + * TODO(developer): Uncomment these variables before running the sample.\ |
| 23 | + * (Not necessary if passing values as arguments) |
| 24 | + */ |
| 25 | + |
| 26 | + // const datasetId = 'YOUR_DATASET_ID'; |
| 27 | + // const project = 'YOUR_PROJECT_ID'; |
| 28 | + // const location = 'YOUR_PROJECT_LOCATION'; |
| 29 | + |
| 30 | + // Imports the Google Cloud Dataset Service Client library |
| 31 | + const {DatasetServiceClient} = require('@google-cloud/aiplatform'); |
| 32 | + |
| 33 | + // Specifies the location of the api endpoint |
| 34 | + const clientOptions = { |
| 35 | + apiEndpoint: 'us-central1-aiplatform.googleapis.com', |
| 36 | + }; |
| 37 | + |
| 38 | + // Instantiates a client |
| 39 | + const datasetServiceClient = new DatasetServiceClient(clientOptions); |
| 40 | + |
| 41 | + async function deleteDataset() { |
| 42 | + // Configure the resource |
| 43 | + const name = datasetServiceClient.datasetPath(project, location, datasetId); |
| 44 | + const request = {name}; |
| 45 | + |
| 46 | + // Delete Dataset Request |
| 47 | + const [response] = await datasetServiceClient.deleteDataset(request); |
| 48 | + console.log(`Long running operation: ${response.name}`); |
| 49 | + |
| 50 | + // Wait for operation to complete |
| 51 | + await response.promise(); |
| 52 | + const result = response.result; |
| 53 | + |
| 54 | + console.log('Delete dataset response:\n', result); |
| 55 | + } |
| 56 | + deleteDataset(); |
| 57 | + // [END aiplatform_delete_dataset_sample] |
| 58 | +} |
| 59 | + |
| 60 | +process.on('unhandledRejection', err => { |
| 61 | + console.error(err.message); |
| 62 | + process.exitCode = 1; |
| 63 | +}); |
| 64 | + |
| 65 | +main(...process.argv.slice(2)); |
0 commit comments