diff --git a/ai-platform/snippets/package.json b/ai-platform/snippets/package.json new file mode 100644 index 0000000000..4944f119e2 --- /dev/null +++ b/ai-platform/snippets/package.json @@ -0,0 +1,21 @@ +{ + "name": "nodejs-aiplatform-samples", + "private": true, + "license": "Apache-2.0", + "author": "Google LLC", + "engines": { + "node": ">=10" + }, + "files": [ + "*.js" + ], + "scripts": { + "test": "mocha --timeout 600000 test/*.js" + }, + "dependencies": { + "@google-cloud/aiplatform": "^0.1.0" + }, + "devDependencies": { + "mocha": "^8.0.0" + } +} diff --git a/ai-platform/snippets/quickstart.js b/ai-platform/snippets/quickstart.js new file mode 100644 index 0000000000..abf6279d52 --- /dev/null +++ b/ai-platform/snippets/quickstart.js @@ -0,0 +1,34 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +/** + * TODO: add an actual quickstart example. + */ +async function main() { + // [START aiplatform_quickstart] + const {DatasetServiceClient} = require('@google-cloud/aiplatform'); + const client = new DatasetServiceClient(); + + // Do something with DatasetServiceClient. + console.info(client); + + // [END aiplatform_quickstart] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err); + process.exitCode = 1; +}); diff --git a/ai-platform/snippets/test/quickstart.test.js b/ai-platform/snippets/test/quickstart.test.js new file mode 100644 index 0000000000..07fb1e0544 --- /dev/null +++ b/ai-platform/snippets/test/quickstart.test.js @@ -0,0 +1,29 @@ +/** + * Copyright 2017, Google, Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +const {describe, it} = require('mocha'); +const assert = require('assert'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe('quickstart', () => { + it('should have functional quickstart', async () => { + const stdout = execSync('node quickstart'); + assert(stdout.match(/DatasetServiceClient/)); + }); +});