From f8900a65f89d8460bbd638d02da93198eaf951d2 Mon Sep 17 00:00:00 2001 From: bradmiro Date: Thu, 24 Oct 2019 15:16:10 -0400 Subject: [PATCH 01/12] Added sample and test for vision-api endpoint-specific calls. --- samples/setEndpoint.js | 38 +++++++++++++++++++++++++ samples/system-test/setEndpoint.test.js | 29 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 samples/setEndpoint.js create mode 100644 samples/system-test/setEndpoint.test.js diff --git a/samples/setEndpoint.js b/samples/setEndpoint.js new file mode 100644 index 00000000..3e0d20a1 --- /dev/null +++ b/samples/setEndpoint.js @@ -0,0 +1,38 @@ +/** + * Copyright 2019, 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'; + + +async function quickstart() { + // [START vision_set_endpoint] + // Imports the Google Cloud client library + const vision = require('@google-cloud/vision'); + + // Specifies the location of the api endpoint + const clientOptions = {'apiEndpoint': 'eu-vision.googleapis.com'}; + + // Creates a client + const client = new vision.ImageAnnotatorClient(clientOptions); + + // Performs label detection on the image file + const [result] = await client.labelDetection('./resources/wakeupcat.jpg'); + const labels = result.labelAnnotations; + console.log('Labels:'); + labels.forEach(label => console.log(label.description)); +} +// [END vision_set_endpoint] + +quickstart().catch(console.error); diff --git a/samples/system-test/setEndpoint.test.js b/samples/system-test/setEndpoint.test.js new file mode 100644 index 00000000..82e92f8b --- /dev/null +++ b/samples/system-test/setEndpoint.test.js @@ -0,0 +1,29 @@ +/** + * Copyright 2019, 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 {assert} = require('chai'); +const cp = require('child_process'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe(`set endpoint for vision api call`, () => { + it(`should detect labels in a remote file from a pre-set api endpoint`, async () => { + const stdout = execSync('node setEndpoint.js'); + assert.match(stdout, /Labels:/); + assert.match(stdout, /cat/); + }); +}); From 9c737c381c06b878f957815697f318ca918caa1c Mon Sep 17 00:00:00 2001 From: bradmiro Date: Thu, 24 Oct 2019 15:24:39 -0400 Subject: [PATCH 02/12] Changed name of endpoint function --- samples/setEndpoint.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/setEndpoint.js b/samples/setEndpoint.js index 3e0d20a1..0d9dab92 100644 --- a/samples/setEndpoint.js +++ b/samples/setEndpoint.js @@ -16,7 +16,7 @@ 'use strict'; -async function quickstart() { +async function setEndpoint() { // [START vision_set_endpoint] // Imports the Google Cloud client library const vision = require('@google-cloud/vision'); @@ -35,4 +35,4 @@ async function quickstart() { } // [END vision_set_endpoint] -quickstart().catch(console.error); +setEndpoint().catch(console.error); From d831fb64e311ece5ddc11a530e72395916800b34 Mon Sep 17 00:00:00 2001 From: bradmiro Date: Thu, 24 Oct 2019 15:32:20 -0400 Subject: [PATCH 03/12] Updated README for 'set endpoint' --- samples/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/samples/README.md b/samples/README.md index 67a854b8..840dcf79 100644 --- a/samples/README.md +++ b/samples/README.md @@ -17,6 +17,7 @@ * [Detect.v1p3beta1](#detect.v1p3beta1) * [Face Detection](#face-detection) * [Quickstart](#quickstart) + * [Set Endpoint](#set-endpoint) * [Text Detection](#text-detection) ## Before you begin @@ -96,6 +97,21 @@ __Usage:__ +### Set Endpoint + +View the [source code]https://github.com/googleapis/nodejs-vision/blob/master/samples/setEndpoint.js) + +[![Open in Cloud shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/setEndpoint.js,samples/README.md) + +__Usage:__ + +`node setEndpoint.js` + +----- + + + + ### Quickstart View the [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/quickstart.js). From 3433f0bf2ca804c089b6ed8204d49352ec3f4e45 Mon Sep 17 00:00:00 2001 From: bradmiro Date: Thu, 24 Oct 2019 15:39:38 -0400 Subject: [PATCH 04/12] Updated the licenses --- samples/setEndpoint.js | 2 +- samples/system-test/setEndpoint.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/setEndpoint.js b/samples/setEndpoint.js index 0d9dab92..3c400bd1 100644 --- a/samples/setEndpoint.js +++ b/samples/setEndpoint.js @@ -1,5 +1,5 @@ /** - * Copyright 2019, Google, Inc. + * 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 diff --git a/samples/system-test/setEndpoint.test.js b/samples/system-test/setEndpoint.test.js index 82e92f8b..d55a7ac9 100644 --- a/samples/system-test/setEndpoint.test.js +++ b/samples/system-test/setEndpoint.test.js @@ -1,5 +1,5 @@ /** - * Copyright 2019, Google, Inc. + * 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 From 91e2379e15985fa3d0bc66f7314705aacb7610f3 Mon Sep 17 00:00:00 2001 From: bradmiro Date: Thu, 24 Oct 2019 16:52:10 -0400 Subject: [PATCH 05/12] Linted and corrected license --- samples/setEndpoint.js | 30 ++++++++++++------------- samples/system-test/setEndpoint.test.js | 27 +++++++++++----------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/samples/setEndpoint.js b/samples/setEndpoint.js index 3c400bd1..f8d2d0c1 100644 --- a/samples/setEndpoint.js +++ b/samples/setEndpoint.js @@ -1,28 +1,26 @@ -/** - * 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. - */ +// 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 +// +// https://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'; - async function setEndpoint() { // [START vision_set_endpoint] // Imports the Google Cloud client library const vision = require('@google-cloud/vision'); // Specifies the location of the api endpoint - const clientOptions = {'apiEndpoint': 'eu-vision.googleapis.com'}; + const clientOptions = {'apiEndpoint': 'eu-vision.googleapis.com'}; // Creates a client const client = new vision.ImageAnnotatorClient(clientOptions); diff --git a/samples/system-test/setEndpoint.test.js b/samples/system-test/setEndpoint.test.js index d55a7ac9..3c7aa2a7 100644 --- a/samples/system-test/setEndpoint.test.js +++ b/samples/system-test/setEndpoint.test.js @@ -1,17 +1,16 @@ -/** - * 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. - */ +// 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 +// +// https://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'; From 37f9ecc84f6bc2772363ef6d1464acca5588bf5f Mon Sep 17 00:00:00 2001 From: bradmiro Date: Thu, 24 Oct 2019 17:20:40 -0400 Subject: [PATCH 06/12] Fixed lint error --- samples/setEndpoint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/setEndpoint.js b/samples/setEndpoint.js index f8d2d0c1..b35d83b0 100644 --- a/samples/setEndpoint.js +++ b/samples/setEndpoint.js @@ -20,7 +20,7 @@ async function setEndpoint() { const vision = require('@google-cloud/vision'); // Specifies the location of the api endpoint - const clientOptions = {'apiEndpoint': 'eu-vision.googleapis.com'}; + const clientOptions = {apiEndpoint: 'eu-vision.googleapis.com'}; // Creates a client const client = new vision.ImageAnnotatorClient(clientOptions); From df93263fb3d7ea75b411dc1058a66f85aecb8010 Mon Sep 17 00:00:00 2001 From: bradmiro Date: Fri, 25 Oct 2019 12:27:22 -0400 Subject: [PATCH 07/12] Updated project and samples READMEs --- README.md | 1 + samples/README.md | 21 +++++++++++---------- samples/setEndpoint.js | 1 + 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a67d392d..f3384201 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ has instructions for running the samples. | Detect.v1p3beta1 | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/detect.v1p3beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/detect.v1p3beta1.js,samples/README.md) | | Face Detection | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/faceDetection.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/faceDetection.js,samples/README.md) | | Quickstart | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | +| Set Endpoint | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/setendpoint.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/setEndpoint.js,samples/README.md) | | Text Detection | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/textDetection.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/textDetection.js,samples/README.md) | diff --git a/samples/README.md b/samples/README.md index 840dcf79..8c8cdf5a 100644 --- a/samples/README.md +++ b/samples/README.md @@ -97,38 +97,39 @@ __Usage:__ -### Set Endpoint +### Quickstart -View the [source code]https://github.com/googleapis/nodejs-vision/blob/master/samples/setEndpoint.js) +View the [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/quickstart.js). -[![Open in Cloud shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/setEndpoint.js,samples/README.md) +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) __Usage:__ -`node setEndpoint.js` ------ +`node quickstart.js` +----- -### Quickstart -View the [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/quickstart.js). -[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) +### Set Endpoint -__Usage:__ +View the [source code]https://github.com/googleapis/nodejs-vision/blob/master/samples/setEndpoint.js) +[![Open in Cloud shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/setEndpoint.js,samples/README.md) -`node quickstart.js` +__Usage:__ +`node setEndpoint.js` ----- + ### Text Detection View the [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/textDetection.js). diff --git a/samples/setEndpoint.js b/samples/setEndpoint.js index b35d83b0..8f4dc145 100644 --- a/samples/setEndpoint.js +++ b/samples/setEndpoint.js @@ -34,3 +34,4 @@ async function setEndpoint() { // [END vision_set_endpoint] setEndpoint().catch(console.error); + \ No newline at end of file From abe29c316bcc4c8eb4340cd848eca29c4f16f81a Mon Sep 17 00:00:00 2001 From: bradmiro Date: Fri, 25 Oct 2019 12:30:04 -0400 Subject: [PATCH 08/12] Added newline to end of setEndpoint.js --- samples/setEndpoint.js | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/setEndpoint.js b/samples/setEndpoint.js index 8f4dc145..b35d83b0 100644 --- a/samples/setEndpoint.js +++ b/samples/setEndpoint.js @@ -34,4 +34,3 @@ async function setEndpoint() { // [END vision_set_endpoint] setEndpoint().catch(console.error); - \ No newline at end of file From c9fc6fe4a1c50c4321d31dbfc0f28cc7361e4daf Mon Sep 17 00:00:00 2001 From: bradmiro Date: Fri, 25 Oct 2019 12:55:43 -0400 Subject: [PATCH 09/12] Fixed broken link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f3384201..27b41e31 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ has instructions for running the samples. | Detect.v1p3beta1 | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/detect.v1p3beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/detect.v1p3beta1.js,samples/README.md) | | Face Detection | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/faceDetection.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/faceDetection.js,samples/README.md) | | Quickstart | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | -| Set Endpoint | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/setendpoint.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/setEndpoint.js,samples/README.md) | +| Set Endpoint | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/setEndpoint.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/setEndpoint.js,samples/README.md) | | Text Detection | [source code](https://github.com/googleapis/nodejs-vision/blob/master/samples/textDetection.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-vision&page=editor&open_in_editor=samples/textDetection.js,samples/README.md) | From ad87b9762e3ccd20735f4fb29e3619f8d56ecdb7 Mon Sep 17 00:00:00 2001 From: bradmiro Date: Mon, 28 Oct 2019 16:44:38 -0400 Subject: [PATCH 10/12] Moved location of END region tag --- samples/setEndpoint.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/setEndpoint.js b/samples/setEndpoint.js index b35d83b0..ef755a96 100644 --- a/samples/setEndpoint.js +++ b/samples/setEndpoint.js @@ -24,6 +24,7 @@ async function setEndpoint() { // Creates a client const client = new vision.ImageAnnotatorClient(clientOptions); + // [END vision_set_endpoint] // Performs label detection on the image file const [result] = await client.labelDetection('./resources/wakeupcat.jpg'); @@ -31,6 +32,7 @@ async function setEndpoint() { console.log('Labels:'); labels.forEach(label => console.log(label.description)); } -// [END vision_set_endpoint] + setEndpoint().catch(console.error); + \ No newline at end of file From 7d358c6b6a6e5a9f2991e0106e695c9e6beac1b8 Mon Sep 17 00:00:00 2001 From: bradmiro Date: Mon, 28 Oct 2019 16:47:08 -0400 Subject: [PATCH 11/12] Lint fix --- samples/setEndpoint.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/setEndpoint.js b/samples/setEndpoint.js index ef755a96..42d90bd3 100644 --- a/samples/setEndpoint.js +++ b/samples/setEndpoint.js @@ -33,6 +33,4 @@ async function setEndpoint() { labels.forEach(label => console.log(label.description)); } - setEndpoint().catch(console.error); - \ No newline at end of file From 348ae3eeeada9e7f96128a43a40c92d088234d1d Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Mon, 28 Oct 2019 18:19:06 -0700 Subject: [PATCH 12/12] chore: ignore setEndpoint in link check --- linkinator.config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linkinator.config.json b/linkinator.config.json index d780d6bf..cad97afd 100644 --- a/linkinator.config.json +++ b/linkinator.config.json @@ -2,6 +2,7 @@ "recurse": true, "skip": [ "https://codecov.io/gh/googleapis/", - "www.googleapis.com" + "www.googleapis.com", + "setEndpoint.js" ] }