Commit 5fba8b00 authored by Syed Bilal Raees's avatar Syed Bilal Raees

chnages

parents
**/node_modules
**/coverage
test/fixtures
build/
docs/
protos/
samples/generated/
{
"extends": "./node_modules/gts"
}
*.ts text eol=lf
*.js text eol=lf
protos/* linguist-generated
**/api-extractor.json linguist-language=JSON-with-Comments
**/*.log
**/node_modules
.coverage
coverage
.nyc_output
docs/
out/
build/
system-test/secrets.js
system-test/*key.json
*.lock
.DS_Store
package-lock.json
__pycache__
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
module.exports = {
opts: {
readme: './README.md',
package: './package.json',
template: './node_modules/jsdoc-fresh',
recurse: true,
verbose: true,
destination: './docs/'
},
plugins: [
'plugins/markdown',
'jsdoc-region-tag'
],
source: {
excludePattern: '(^|\\/|\\\\)[._]',
include: [
'build/src',
'protos'
],
includePattern: '\\.js$'
},
templates: {
copyright: 'Copyright 2022 Google LLC',
includeDate: false,
sourceFiles: false,
systemName: '@google-cloud/retail',
theme: 'lumen',
default: {
outputSourceFiles: false
}
},
markdown: {
idInHeadings: true
}
};
# Format: //devtools/kokoro/config/proto/build.proto
# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}
# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
# Use the trampoline script to run in docker.
build_file: "nodejs-retail/.kokoro/trampoline_v2.sh"
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/nodejs-retail/.kokoro/test.sh"
}
#!/bin/bash
# Copyright 2020 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.
# This file is called in the early stage of `trampoline_v2.sh` to
# populate secrets needed for the CI builds.
set -eo pipefail
function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
function msg { println "$*" >&2 ;}
function println { printf '%s\n' "$(now) $*" ;}
# Populates requested secrets set in SECRET_MANAGER_KEYS
# In Kokoro CI builds, we use the service account attached to the
# Kokoro VM. This means we need to setup auth on other CI systems.
# For local run, we just use the gcloud command for retrieving the
# secrets.
if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then
GCLOUD_COMMANDS=(
"docker"
"run"
"--entrypoint=gcloud"
"--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR}"
"gcr.io/google.com/cloudsdktool/cloud-sdk"
)
if [[ "${TRAMPOLINE_CI:-}" == "kokoro" ]]; then
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
else
echo "Authentication for this CI system is not implemented yet."
exit 2
# TODO: Determine appropriate SECRET_LOCATION and the GCLOUD_COMMANDS.
fi
else
# For local run, use /dev/shm or temporary directory for
# KOKORO_GFILE_DIR.
if [[ -d "/dev/shm" ]]; then
export KOKORO_GFILE_DIR=/dev/shm
else
export KOKORO_GFILE_DIR=$(mktemp -d -t ci-XXXXXXXX)
fi
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
GCLOUD_COMMANDS=("gcloud")
fi
msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
mkdir -p ${SECRET_LOCATION}
for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
do
msg "Retrieving secret ${key}"
"${GCLOUD_COMMANDS[@]}" \
secrets versions access latest \
--project cloud-devrel-kokoro-resources \
--secret $key > \
"$SECRET_LOCATION/$key"
if [[ $? == 0 ]]; then
msg "Secret written to ${SECRET_LOCATION}/${key}"
else
msg "Error retrieving secret ${key}"
exit 2
fi
done
# Format: //devtools/kokoro/config/proto/build.proto
# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}
# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
# Use the trampoline script to run in docker.
build_file: "nodejs-retail/.kokoro/trampoline_v2.sh"
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/nodejs-retail/.kokoro/test.sh"
}
# Download resources for system tests (service account key, etc.)
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs"
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/nodejs-retail/.kokoro/samples-test.sh"
}
# Download resources for system tests (service account key, etc.)
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs"
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/nodejs-retail/.kokoro/system-test.sh"
}
#!/bin/bash
# Copyright 2022 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.
set -eo pipefail
export NPM_CONFIG_PREFIX=${HOME}/.npm-global
# Setup service account credentials.
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
export GCLOUD_PROJECT=long-door-651
cd $(dirname $0)/..
# Run a pre-test hook, if a pre-samples-test.sh is in the project
if [ -f .kokoro/pre-samples-test.sh ]; then
set +x
. .kokoro/pre-samples-test.sh
set -x
fi
if [ -f samples/package.json ]; then
# Install and link samples
cd samples/
npm install
# If tests are running against main branch, configure flakybot
# to open issues on failures:
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then
export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml
export MOCHA_REPORTER=xunit
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
}
trap cleanup EXIT HUP
fi
npm run test
fi
# codecov combines coverage across integration and unit tests. Include
# the logic below for any environment you wish to collect coverage for:
COVERAGE_NODE=12
if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then
NYC_BIN=./node_modules/nyc/bin/nyc.js
if [ -f "$NYC_BIN" ]; then
$NYC_BIN report || true
fi
bash $KOKORO_GFILE_DIR/codecov.sh
else
echo "coverage is only reported for Node $COVERAGE_NODE"
fi
#!/bin/bash
# Copyright 2022 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.
set -eo pipefail
echo "no-op"
#!/bin/bash
# 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.
# This file is not used any more, but we keep this file for making it
# easy to roll back.
# TODO: Remove this file from the template.
set -eo pipefail
# Always run the cleanup script, regardless of the success of bouncing into
# the container.
function cleanup() {
chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
echo "cleanup";
}
trap cleanup EXIT
$(dirname $0)/populate-secrets.sh # Secret Manager secrets.
python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py"
This diff is collapsed.
// Copyright 2020 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.
const config = {
"enable-source-maps": true,
"throw-deprecation": true,
"timeout": 10000,
"recursive": true
}
if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
delete config['throw-deprecation'];
}
if (process.env.MOCHA_REPORTER) {
config.reporter = process.env.MOCHA_REPORTER;
}
if (process.env.MOCHA_REPORTER_OUTPUT) {
config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`;
}
module.exports = config
{
"report-dir": "./.coverage",
"reporter": ["text", "lcov"],
"exclude": [
"**/*-test",
"**/.coverage",
"**/apis",
"**/benchmark",
"**/conformance",
"**/docs",
"**/samples",
"**/scripts",
"**/protos",
"**/test",
"**/*.d.ts",
".jsdoc.js",
"**/.jsdoc.js",
"karma.conf.js",
"webpack-tests.config.js",
"webpack.config.js"
],
"exclude-after-remap": false,
"all": true
}
**/node_modules
**/coverage
test/fixtures
build/
docs/
protos/
// Copyright 2020 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.
module.exports = {
...require('gts/.prettierrc.json')
}
{
"client_documentation": "https://cloud.google.com/nodejs/docs/reference/retail/latest",
"api_id": "retail.googleapis.com",
"distribution_name": "@google-cloud/retail",
"release_level": "stable",
"default_version": "v2beta",
"language": "nodejs",
"name_pretty": "Retail API",
"repo": "googleapis/nodejs-retail",
"product_documentation": "https://cloud.google.com/recommendations/",
"requires_billing": true,
"name": "retail",
"issue_tracker": "https://github.com/googleapis/nodejs-retail/issues",
"api_shortname": "retail",
"library_type": "GAPIC_AUTO",
"codeowner_team": "@googleapis/cloud-retail-team"
}
# Copyright 2020 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.
# Template for .trampolinerc
# Add required env vars here.
required_envvars+=(
)
# Add env vars which are passed down into the container here.
pass_down_envvars+=(
"AUTORELEASE_PR"
"VERSION"
)
# Prevent unintentional override on the default image.
if [[ "${TRAMPOLINE_IMAGE_UPLOAD:-false}" == "true" ]] && \
[[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then
echo "Please set TRAMPOLINE_IMAGE if you want to upload the Docker image."
exit 1
fi
# Define the default value if it makes sense.
if [[ -z "${TRAMPOLINE_IMAGE_UPLOAD:-}" ]]; then
TRAMPOLINE_IMAGE_UPLOAD=""
fi
if [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then
TRAMPOLINE_IMAGE=""
fi
if [[ -z "${TRAMPOLINE_DOCKERFILE:-}" ]]; then
TRAMPOLINE_DOCKERFILE=""
fi
if [[ -z "${TRAMPOLINE_BUILD_FILE:-}" ]]; then
TRAMPOLINE_BUILD_FILE=""
fi
# Secret Manager secrets.
source ${PROJECT_ROOT}/.kokoro/populate-secrets.sh
const express = require('express');
const app = express();
const cors = require('cors');
app.use(cors());
app.options('*', cors());
const bodyParser = require('body-parser')
app.use(bodyParser.json());
console.log('App Running...')
const searchService = require('./samples/interactive-tutorials/search/search-simple-query');
app.get('/search', (req, res) => {
searchService(req.query.text)
.then(result => {
// console.log('Resultss', result);
return res.send(result);
})
.catch(err => res.send(err))
});
app.listen(3002);
**_THIS REPOSITORY IS DEPRECATED. ALL OF ITS CONTENT AND HISTORY HAS BEEN MOVED TO [GOOGLE-CLOUD-NODE](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-retail)_**
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
[//]: # "To regenerate it, use `python -m synthtool`."
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
# [Retail API: Node.js Client](https://github.com/googleapis/nodejs-retail)
[![release level](https://img.shields.io/badge/release%20level-stable-brightgreen.svg?style=flat)](https://cloud.google.com/terms/launch-stages)
[![npm version](https://img.shields.io/npm/v/@google-cloud/retail.svg)](https://www.npmjs.org/package/@google-cloud/retail)
Retail client for Node.js
A comprehensive list of changes in each version may be found in
[the CHANGELOG](https://github.com/googleapis/nodejs-retail/blob/main/CHANGELOG.md).
* [Retail API Node.js Client API Reference][client-docs]
* [Retail API Documentation][product-docs]
* [github.com/googleapis/nodejs-retail](https://github.com/googleapis/nodejs-retail)
Read more about the client libraries for Cloud APIs, including the older
Google APIs Client Libraries, in [Client Libraries Explained][explained].
[explained]: https://cloud.google.com/apis/docs/client-libraries-explained
**Table of contents:**
* [Quickstart](#quickstart)
* [Before you begin](#before-you-begin)
* [Installing the client library](#installing-the-client-library)
* [Using the client library](#using-the-client-library)
* [Samples](#samples)
* [Versioning](#versioning)
* [Contributing](#contributing)
* [License](#license)
## Quickstart
### Before you begin
1. [Select or create a Cloud Platform project][projects].
1. [Enable billing for your project][billing].
1. [Enable the Retail API API][enable_api].
1. [Set up authentication with a service account][auth] so you can access the
API from your local workstation.
### Installing the client library
```bash
npm install @google-cloud/retail
```
### Using the client library
```javascript
// Imports the Google Cloud client library
const {CatalogServiceClient} = require('@google-cloud/retail');
// TODO(developer): uncomment these variables with your information
// const projectId = 'my-project'
// const location = 'global'
// Creates a client
const client = new CatalogServiceClient();
async function listCatalogs() {
const catalogs = await client.listCatalogs({
parent: `projects/${projectId}/locations/${location}`,
});
console.info(catalogs);
}
listCatalogs();
```
## Samples
Samples are in the [`samples/`](https://github.com/googleapis/nodejs-retail/tree/main/samples) directory. Each sample's `README.md` has instructions for running its sample.
| Sample | Source Code | Try it |
| --------------------------- | --------------------------------- | ------ |
| Quickstart | [source code](https://github.com/googleapis/nodejs-retail/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-retail&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
The [Retail API Node.js Client API Reference][client-docs] documentation
also contains samples.
## Supported Node.js Versions
Our client libraries follow the [Node.js release schedule](https://nodejs.org/en/about/releases/).
Libraries are compatible with all current _active_ and _maintenance_ versions of
Node.js.
If you are using an end-of-life version of Node.js, we recommend that you update
as soon as possible to an actively supported LTS version.
Google's client libraries support legacy versions of Node.js runtimes on a
best-efforts basis with the following warnings:
* Legacy versions are not tested in continuous integration.
* Some security patches and features cannot be backported.
* Dependencies cannot be kept up-to-date.
Client libraries targeting some end-of-life versions of Node.js are available, and
can be installed through npm [dist-tags](https://docs.npmjs.com/cli/dist-tag).
The dist-tags follow the naming convention `legacy-(version)`.
For example, `npm install @google-cloud/retail@legacy-8` installs client libraries
for versions compatible with Node.js 8.
## Versioning
This library follows [Semantic Versioning](http://semver.org/).
This library is considered to be **stable**. The code surface will not change in backwards-incompatible ways
unless absolutely necessary (e.g. because of critical security issues) or with
an extensive deprecation period. Issues and requests against **stable** libraries
are addressed with the highest priority.
More Information: [Google Cloud Platform Launch Stages][launch_stages]
[launch_stages]: https://cloud.google.com/terms/launch-stages
## Contributing
Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-retail/blob/main/CONTRIBUTING.md).
Please note that this `README.md`, the `samples/README.md`,
and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`)
are generated from a central template. To edit one of these files, make an edit
to its templates in
[directory](https://github.com/googleapis/synthtool).
## License
Apache Version 2.0
See [LICENSE](https://github.com/googleapis/nodejs-retail/blob/main/LICENSE)
[client-docs]: https://cloud.google.com/nodejs/docs/reference/retail/latest
[product-docs]: https://cloud.google.com/recommendations/
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
[projects]: https://console.cloud.google.com/project
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=retail.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/getting-started
# Copyright 2022 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.
import synthtool.languages.node as node
node.owlbot_main(templates_excludes=[
'README.md'
])
{
"name": "test-app",
"version": "1.0.0",
"main": "App.js",
"dependencies": {
"body-parser": "^1.20.1",
"cors": "^2.8.5",
"express": "^4.18.2",
"googleapis": "^109.0.1",
"nodemon": "^2.0.20"
},
"scripts": {
"dev": "nodemon App.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": ""
}
{
"timeout": "600000",
"recursive": true,
"spec": ["test/*.js", "interactive-tutorials/test/*.js"]
}
\ No newline at end of file
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
[//]: # "To regenerate it, use `python -m synthtool`."
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
# [Retail API: Node.js Samples](https://github.com/googleapis/nodejs-retail)
[![Open in Cloud Shell][shell_img]][shell_link]
## Table of Contents
* [Before you begin](#before-you-begin)
* [Samples](#samples)
* [Quickstart](#quickstart)
## Before you begin
Before running the samples, make sure you've followed the steps outlined in
[Using the client library](https://github.com/googleapis/nodejs-retail#using-the-client-library).
`cd samples`
`npm install`
`cd ..`
## Samples
### Quickstart
View the [source code](https://github.com/googleapis/nodejs-retail/blob/main/samples/quickstart.js).
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-retail&page=editor&open_in_editor=samples/quickstart.js,samples/README.md)
__Usage:__
`node samples/quickstart.js`
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-retail&page=editor&open_in_editor=samples/README.md
[product-docs]: https://cloud.google.com/recommendations/
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(attributesConfig, catalogAttribute) {
// [START retail_v2_generated_CatalogService_AddCatalogAttribute_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full AttributesConfig resource name. Format:
* `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
*/
// const attributesConfig = 'abc123'
/**
* Required. The CatalogAttribute google.cloud.retail.v2.CatalogAttribute
* to add.
*/
// const catalogAttribute = {}
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callAddCatalogAttribute() {
// Construct request
const request = {
attributesConfig,
catalogAttribute,
};
// Run request
const response = await retailClient.addCatalogAttribute(request);
console.log(response);
}
callAddCatalogAttribute();
// [END retail_v2_generated_CatalogService_AddCatalogAttribute_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(name) {
// [START retail_v2_generated_CatalogService_GetAttributesConfig_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full AttributesConfig resource name. Format:
* `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
*/
// const name = 'abc123'
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callGetAttributesConfig() {
// Construct request
const request = {
name,
};
// Run request
const response = await retailClient.getAttributesConfig(request);
console.log(response);
}
callGetAttributesConfig();
// [END retail_v2_generated_CatalogService_GetAttributesConfig_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(name) {
// [START retail_v2_generated_CatalogService_GetCompletionConfig_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full CompletionConfig resource name. Format:
* projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig
*/
// const name = 'abc123'
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callGetCompletionConfig() {
// Construct request
const request = {
name,
};
// Run request
const response = await retailClient.getCompletionConfig(request);
console.log(response);
}
callGetCompletionConfig();
// [END retail_v2_generated_CatalogService_GetCompletionConfig_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main() {
// [START retail_v2_generated_CatalogService_GetDefaultBranch_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* The parent catalog resource name, such as
* `projects/* /locations/global/catalogs/default_catalog`.
*/
// const catalog = 'abc123'
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callGetDefaultBranch() {
// Construct request
const request = {
};
// Run request
const response = await retailClient.getDefaultBranch(request);
console.log(response);
}
callGetDefaultBranch();
// [END retail_v2_generated_CatalogService_GetDefaultBranch_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent) {
// [START retail_v2_generated_CatalogService_ListCatalogs_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The account resource name with an associated location.
* If the caller does not have permission to list
* Catalog google.cloud.retail.v2.Catalog s under this location, regardless
* of whether or not this location exists, a PERMISSION_DENIED error is
* returned.
*/
// const parent = 'abc123'
/**
* Maximum number of Catalog google.cloud.retail.v2.Catalog s to return. If
* unspecified, defaults to 50. The maximum allowed value is 1000. Values
* above 1000 will be coerced to 1000.
* If this field is negative, an INVALID_ARGUMENT is returned.
*/
// const pageSize = 1234
/**
* A page token
* ListCatalogsResponse.next_page_token google.cloud.retail.v2.ListCatalogsResponse.next_page_token,
* received from a previous
* CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs
* call. Provide this to retrieve the subsequent page.
* When paginating, all other parameters provided to
* CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs
* must match the call that provided the page token. Otherwise, an
* INVALID_ARGUMENT error is returned.
*/
// const pageToken = 'abc123'
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callListCatalogs() {
// Construct request
const request = {
parent,
};
// Run request
const iterable = await retailClient.listCatalogsAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListCatalogs();
// [END retail_v2_generated_CatalogService_ListCatalogs_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(attributesConfig, key) {
// [START retail_v2_generated_CatalogService_RemoveCatalogAttribute_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full AttributesConfig resource name. Format:
* `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
*/
// const attributesConfig = 'abc123'
/**
* Required. The attribute name key of the
* CatalogAttribute google.cloud.retail.v2.CatalogAttribute to remove.
*/
// const key = 'abc123'
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callRemoveCatalogAttribute() {
// Construct request
const request = {
attributesConfig,
key,
};
// Run request
const response = await retailClient.removeCatalogAttribute(request);
console.log(response);
}
callRemoveCatalogAttribute();
// [END retail_v2_generated_CatalogService_RemoveCatalogAttribute_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(attributesConfig, catalogAttribute) {
// [START retail_v2_generated_CatalogService_ReplaceCatalogAttribute_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full AttributesConfig resource name. Format:
* `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig`
*/
// const attributesConfig = 'abc123'
/**
* Required. The updated
* CatalogAttribute google.cloud.retail.v2.CatalogAttribute.
*/
// const catalogAttribute = {}
/**
* Indicates which fields in the provided
* CatalogAttribute google.cloud.retail.v2.CatalogAttribute to update. The
* following are NOT supported:
* * CatalogAttribute.key google.cloud.retail.v2.CatalogAttribute.key
* If not set, all supported fields are updated.
*/
// const updateMask = {}
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callReplaceCatalogAttribute() {
// Construct request
const request = {
attributesConfig,
catalogAttribute,
};
// Run request
const response = await retailClient.replaceCatalogAttribute(request);
console.log(response);
}
callReplaceCatalogAttribute();
// [END retail_v2_generated_CatalogService_ReplaceCatalogAttribute_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main() {
// [START retail_v2_generated_CatalogService_SetDefaultBranch_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Full resource name of the catalog, such as
* `projects/* /locations/global/catalogs/default_catalog`.
*/
// const catalog = 'abc123'
/**
* The final component of the resource name of a branch.
* This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT
* error is returned.
* If there are no sufficient active products in the targeted branch and
* force google.cloud.retail.v2.SetDefaultBranchRequest.force is not set, a
* FAILED_PRECONDITION error is returned.
*/
// const branchId = 'abc123'
/**
* Some note on this request, this can be retrieved by
* CatalogService.GetDefaultBranch google.cloud.retail.v2.CatalogService.GetDefaultBranch
* before next valid default branch set occurs.
* This field must be a UTF-8 encoded string with a length limit of 1,000
* characters. Otherwise, an INVALID_ARGUMENT error is returned.
*/
// const note = 'abc123'
/**
* If set to true, it permits switching to a branch with
* branch_id google.cloud.retail.v2.SetDefaultBranchRequest.branch_id even
* if it has no sufficient active products.
*/
// const force = true
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callSetDefaultBranch() {
// Construct request
const request = {
};
// Run request
const response = await retailClient.setDefaultBranch(request);
console.log(response);
}
callSetDefaultBranch();
// [END retail_v2_generated_CatalogService_SetDefaultBranch_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(attributesConfig) {
// [START retail_v2_generated_CatalogService_UpdateAttributesConfig_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The AttributesConfig google.cloud.retail.v2.AttributesConfig
* to update.
*/
// const attributesConfig = {}
/**
* Indicates which fields in the provided
* AttributesConfig google.cloud.retail.v2.AttributesConfig to update. The
* following is the only supported field:
* * AttributesConfig.catalog_attributes google.cloud.retail.v2.AttributesConfig.catalog_attributes
* If not set, all supported fields are updated.
*/
// const updateMask = {}
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callUpdateAttributesConfig() {
// Construct request
const request = {
attributesConfig,
};
// Run request
const response = await retailClient.updateAttributesConfig(request);
console.log(response);
}
callUpdateAttributesConfig();
// [END retail_v2_generated_CatalogService_UpdateAttributesConfig_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(catalog) {
// [START retail_v2_generated_CatalogService_UpdateCatalog_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The Catalog google.cloud.retail.v2.Catalog to update.
* If the caller does not have permission to update the
* Catalog google.cloud.retail.v2.Catalog, regardless of whether or not it
* exists, a PERMISSION_DENIED error is returned.
* If the Catalog google.cloud.retail.v2.Catalog to update does not exist,
* a NOT_FOUND error is returned.
*/
// const catalog = {}
/**
* Indicates which fields in the provided
* Catalog google.cloud.retail.v2.Catalog to update.
* If an unsupported or unknown field is provided, an INVALID_ARGUMENT error
* is returned.
*/
// const updateMask = {}
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callUpdateCatalog() {
// Construct request
const request = {
catalog,
};
// Run request
const response = await retailClient.updateCatalog(request);
console.log(response);
}
callUpdateCatalog();
// [END retail_v2_generated_CatalogService_UpdateCatalog_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(completionConfig) {
// [START retail_v2_generated_CatalogService_UpdateCompletionConfig_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The CompletionConfig google.cloud.retail.v2.CompletionConfig
* to update.
* If the caller does not have permission to update the
* CompletionConfig google.cloud.retail.v2.CompletionConfig, then a
* PERMISSION_DENIED error is returned.
* If the CompletionConfig google.cloud.retail.v2.CompletionConfig to
* update does not exist, a NOT_FOUND error is returned.
*/
// const completionConfig = {}
/**
* Indicates which fields in the provided
* CompletionConfig google.cloud.retail.v2.CompletionConfig to update. The
* following are the only supported fields:
* * CompletionConfig.matching_order google.cloud.retail.v2.CompletionConfig.matching_order
* * CompletionConfig.max_suggestions google.cloud.retail.v2.CompletionConfig.max_suggestions
* * CompletionConfig.min_prefix_length google.cloud.retail.v2.CompletionConfig.min_prefix_length
* * CompletionConfig.auto_learning google.cloud.retail.v2.CompletionConfig.auto_learning
* If not set, all supported fields are updated.
*/
// const updateMask = {}
// Imports the Retail library
const {CatalogServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CatalogServiceClient();
async function callUpdateCompletionConfig() {
// Construct request
const request = {
completionConfig,
};
// Run request
const response = await retailClient.updateCompletionConfig(request);
console.log(response);
}
callUpdateCompletionConfig();
// [END retail_v2_generated_CatalogService_UpdateCompletionConfig_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(catalog, query) {
// [START retail_v2_generated_CompletionService_CompleteQuery_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Catalog for which the completion is performed.
* Full resource name of catalog, such as
* `projects/* /locations/global/catalogs/default_catalog`.
*/
// const catalog = 'abc123'
/**
* Required. The query used to generate suggestions.
* The maximum number of allowed characters is 255.
*/
// const query = 'abc123'
/**
* Required field. A unique identifier for tracking visitors. For example,
* this could be implemented with an HTTP cookie, which should be able to
* uniquely identify a visitor on a single device. This unique identifier
* should not change if the visitor logs in or out of the website.
* The field must be a UTF-8 encoded string with a length limit of 128
* characters. Otherwise, an INVALID_ARGUMENT error is returned.
*/
// const visitorId = 'abc123'
/**
* Note that this field applies for `user-data` dataset only. For requests
* with `cloud-retail` dataset, setting this field has no effect.
* The language filters applied to the output suggestions. If set, it should
* contain the language of the query. If not set, suggestions are returned
* without considering language restrictions. This is the BCP-47 language
* code, such as "en-US" or "sr-Latn". For more information, see Tags for
* Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum
* number of language codes is 3.
*/
// const languageCodes = 'abc123'
/**
* The device type context for completion suggestions.
* It is useful to apply different suggestions on different device types, e.g.
* `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device
* types.
* Supported formats:
* * `UNKNOWN_DEVICE_TYPE`
* * `DESKTOP`
* * `MOBILE`
* * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`.
*/
// const deviceType = 'abc123'
/**
* Determines which dataset to use for fetching completion. "user-data" will
* use the imported dataset through
* CompletionService.ImportCompletionData google.cloud.retail.v2.CompletionService.ImportCompletionData.
* "cloud-retail" will use the dataset generated by cloud retail based on user
* events. If leave empty, it will use the "user-data".
* Current supported values:
* * user-data
* * cloud-retail:
* This option requires enabling auto-learning function first. See
* guidelines (https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset).
*/
// const dataset = 'abc123'
/**
* Completion max suggestions. If left unset or set to 0, then will fallback
* to the configured value
* CompletionConfig.max_suggestions google.cloud.retail.v2.CompletionConfig.max_suggestions.
* The maximum allowed max suggestions is 20. If it is set higher, it will be
* capped by 20.
*/
// const maxSuggestions = 1234
// Imports the Retail library
const {CompletionServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CompletionServiceClient();
async function callCompleteQuery() {
// Construct request
const request = {
catalog,
query,
};
// Run request
const response = await retailClient.completeQuery(request);
console.log(response);
}
callCompleteQuery();
// [END retail_v2_generated_CompletionService_CompleteQuery_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent, inputConfig) {
// [START retail_v2_generated_CompletionService_ImportCompletionData_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The catalog which the suggestions dataset belongs to.
* Format: `projects/1234/locations/global/catalogs/default_catalog`.
*/
// const parent = 'abc123'
/**
* Required. The desired input location of the data.
*/
// const inputConfig = {}
/**
* Pub/Sub topic for receiving notification. If this field is set,
* when the import is finished, a notification is sent to
* specified Pub/Sub topic. The message data is JSON string of a
* Operation google.longrunning.Operation.
* Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`.
*/
// const notificationPubsubTopic = 'abc123'
// Imports the Retail library
const {CompletionServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new CompletionServiceClient();
async function callImportCompletionData() {
// Construct request
const request = {
parent,
inputConfig,
};
// Run request
const [operation] = await retailClient.importCompletionData(request);
const [response] = await operation.promise();
console.log(response);
}
callImportCompletionData();
// [END retail_v2_generated_CompletionService_ImportCompletionData_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent, control, controlId) {
// [START retail_v2_generated_ControlService_CreateControl_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full resource name of parent catalog. Format:
* `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
*/
// const parent = 'abc123'
/**
* Required. The Control to create.
*/
// const control = {}
/**
* Required. The ID to use for the Control, which will become the final
* component of the Control's resource name.
* This value should be 4-63 characters, and valid characters
* are /[a-z][0-9]-_/.
*/
// const controlId = 'abc123'
// Imports the Retail library
const {ControlServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ControlServiceClient();
async function callCreateControl() {
// Construct request
const request = {
parent,
control,
controlId,
};
// Run request
const response = await retailClient.createControl(request);
console.log(response);
}
callCreateControl();
// [END retail_v2_generated_ControlService_CreateControl_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(name) {
// [START retail_v2_generated_ControlService_DeleteControl_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the Control to delete. Format:
* `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}`
*/
// const name = 'abc123'
// Imports the Retail library
const {ControlServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ControlServiceClient();
async function callDeleteControl() {
// Construct request
const request = {
name,
};
// Run request
const response = await retailClient.deleteControl(request);
console.log(response);
}
callDeleteControl();
// [END retail_v2_generated_ControlService_DeleteControl_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(name) {
// [START retail_v2_generated_ControlService_GetControl_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the Control to get. Format:
* `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}`
*/
// const name = 'abc123'
// Imports the Retail library
const {ControlServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ControlServiceClient();
async function callGetControl() {
// Construct request
const request = {
name,
};
// Run request
const response = await retailClient.getControl(request);
console.log(response);
}
callGetControl();
// [END retail_v2_generated_ControlService_GetControl_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent) {
// [START retail_v2_generated_ControlService_ListControls_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The catalog resource name. Format:
* `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
*/
// const parent = 'abc123'
/**
* Optional. Maximum number of results to return. If unspecified, defaults
* to 50. Max allowed value is 1000.
*/
// const pageSize = 1234
/**
* Optional. A page token, received from a previous `ListControls` call.
* Provide this to retrieve the subsequent page.
*/
// const pageToken = 'abc123'
/**
* Optional. A filter to apply on the list results. Supported features:
* * List all the products under the parent branch if
* filter google.cloud.retail.v2.ListControlsRequest.filter is unset.
* * List controls that are used in a single ServingConfig:
* 'serving_config = "boosted_home_page_cvr"'
*/
// const filter = 'abc123'
// Imports the Retail library
const {ControlServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ControlServiceClient();
async function callListControls() {
// Construct request
const request = {
parent,
};
// Run request
const iterable = await retailClient.listControlsAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListControls();
// [END retail_v2_generated_ControlService_ListControls_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(control) {
// [START retail_v2_generated_ControlService_UpdateControl_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The Control to update.
*/
// const control = {}
/**
* Indicates which fields in the provided
* Control google.cloud.retail.v2.Control to update. The following are NOT
* supported:
* * Control.name google.cloud.retail.v2.Control.name
* If not set or empty, all supported fields are updated.
*/
// const updateMask = {}
// Imports the Retail library
const {ControlServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ControlServiceClient();
async function callUpdateControl() {
// Construct request
const request = {
control,
};
// Run request
const response = await retailClient.updateControl(request);
console.log(response);
}
callUpdateControl();
// [END retail_v2_generated_ControlService_UpdateControl_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(placement, userEvent) {
// [START retail_v2_generated_PredictionService_Predict_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full resource name of the format:
* `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}`
* or
* `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`.
* We recommend using the `servingConfigs` resource. `placements` is a legacy
* resource.
* The ID of the Recommendations AI serving config or placement.
* Before you can request predictions from your model, you must create at
* least one serving config or placement for it. For more information, see
* Managing serving configurations
* (https://cloud.google.com/retail/docs/manage-configs).
* The full list of available serving configs can be seen at
* https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs
*/
// const placement = 'abc123'
/**
* Required. Context about the user, what they are looking at and what action
* they took to trigger the predict request. Note that this user event detail
* won't be ingested to userEvent logs. Thus, a separate userEvent write
* request is required for event logging.
* Don't set
* UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id or
* UserInfo.user_id google.cloud.retail.v2.UserInfo.user_id to the same
* fixed ID for different users. If you are trying to receive non-personalized
* recommendations (not recommended; this can negatively impact model
* performance), instead set
* UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id to a
* random unique ID and leave
* UserInfo.user_id google.cloud.retail.v2.UserInfo.user_id unset.
*/
// const userEvent = {}
/**
* Maximum number of results to return. Set this property to the number of
* prediction results needed. If zero, the service will choose a reasonable
* default. The maximum allowed value is 100. Values above 100 will be coerced
* to 100.
*/
// const pageSize = 1234
/**
* This field is not used; leave it unset.
*/
// const pageToken = 'abc123'
/**
* Filter for restricting prediction results with a length limit of 5,000
* characters. Accepts values for tags and the `filterOutOfStockItems` flag.
* * Tag expressions. Restricts predictions to products that match all of the
* specified tags. Boolean operators `OR` and `NOT` are supported if the
* expression is enclosed in parentheses, and must be separated from the
* tag values by a space. `-"tagA"` is also supported and is equivalent to
* `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings
* with a size limit of 1,000 characters.
* Note: "Recently viewed" models don't support tag filtering at the
* moment.
* * filterOutOfStockItems. Restricts predictions to products that do not
* have a
* stockState value of OUT_OF_STOCK.
* Examples:
* * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional")
* * filterOutOfStockItems tag=(-"promotional")
* * filterOutOfStockItems
* If your filter blocks all prediction results, the API will return generic
* (unfiltered) popular products. If you only want results strictly matching
* the filters, set `strictFiltering` to True in `PredictRequest.params` to
* receive empty results instead.
* Note that the API will never return items with storageStatus of "EXPIRED"
* or "DELETED" regardless of filter choices.
* If `filterSyntaxV2` is set to true under the `params` field, then
* attribute-based expressions are expected instead of the above described
* tag-based syntax. Examples:
* * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones"))
* * (availability: ANY("IN_STOCK")) AND
* (colors: ANY("Red") OR categories: ANY("Phones"))
*/
// const filter = 'abc123'
/**
* Use validate only mode for this prediction query. If set to true, a
* dummy model will be used that returns arbitrary products.
* Note that the validate only mode should only be used for testing the API,
* or if the model is not ready.
*/
// const validateOnly = true
/**
* Additional domain specific parameters for the predictions.
* Allowed values:
* * `returnProduct`: Boolean. If set to true, the associated product
* object will be returned in the `results.metadata` field in the
* prediction response.
* * `returnScore`: Boolean. If set to true, the prediction 'score'
* corresponding to each returned product will be set in the
* `results.metadata` field in the prediction response. The given
* 'score' indicates the probability of an product being clicked/purchased
* given the user's context and history.
* * `strictFiltering`: Boolean. True by default. If set to false, the service
* will return generic (unfiltered) popular products instead of empty if
* your filter blocks all prediction results.
* * `priceRerankLevel`: String. Default empty. If set to be non-empty, then
* it needs to be one of {'no-price-reranking', 'low-price-reranking',
* 'medium-price-reranking', 'high-price-reranking'}. This gives
* request-level control and adjusts prediction results based on product
* price.
* * `diversityLevel`: String. Default empty. If set to be non-empty, then
* it needs to be one of {'no-diversity', 'low-diversity',
* 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives
* request-level control and adjusts prediction results based on product
* category.
* * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter`
* field is interpreteted according to the new, attribute-based syntax.
*/
// const params = 1234
/**
* The labels applied to a resource must meet the following requirements:
* * Each resource can have multiple labels, up to a maximum of 64.
* * Each label must be a key-value pair.
* * Keys have a minimum length of 1 character and a maximum length of 63
* characters and cannot be empty. Values can be empty and have a maximum
* length of 63 characters.
* * Keys and values can contain only lowercase letters, numeric characters,
* underscores, and dashes. All characters must use UTF-8 encoding, and
* international characters are allowed.
* * The key portion of a label must be unique. However, you can use the same
* key with multiple resources.
* * Keys must start with a lowercase letter or international character.
* See Google Cloud
* Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
* for more details.
*/
// const labels = 1234
// Imports the Retail library
const {PredictionServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new PredictionServiceClient();
async function callPredict() {
// Construct request
const request = {
placement,
userEvent,
};
// Run request
const response = await retailClient.predict(request);
console.log(response);
}
callPredict();
// [END retail_v2_generated_PredictionService_Predict_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(product, type, placeIds) {
// [START retail_v2_generated_ProductService_AddFulfillmentPlaces_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full resource name of Product google.cloud.retail.v2.Product,
* such as
* `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`.
* If the caller does not have permission to access the
* Product google.cloud.retail.v2.Product, regardless of whether or not it
* exists, a PERMISSION_DENIED error is returned.
*/
// const product = 'abc123'
/**
* Required. The fulfillment type, including commonly used types (such as
* pickup in store and same day delivery), and custom types.
* Supported values:
* * "pickup-in-store"
* * "ship-to-store"
* * "same-day-delivery"
* * "next-day-delivery"
* * "custom-type-1"
* * "custom-type-2"
* * "custom-type-3"
* * "custom-type-4"
* * "custom-type-5"
* If this field is set to an invalid value other than these, an
* INVALID_ARGUMENT error is returned.
* This field directly corresponds to
* Product.fulfillment_info.type google.cloud.retail.v2.FulfillmentInfo.type.
*/
// const type = 'abc123'
/**
* Required. The IDs for this
* type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type, such as
* the store IDs for "pickup-in-store" or the region IDs for
* "same-day-delivery" to be added for this
* type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type. Duplicate
* IDs will be automatically ignored.
* At least 1 value is required, and a maximum of 2000 values are allowed.
* Each value must be a string with a length limit of 10 characters, matching
* the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an
* INVALID_ARGUMENT error is returned.
* If the total number of place IDs exceeds 2000 for this
* type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type after
* adding, then the update will be rejected.
*/
// const placeIds = 'abc123'
/**
* The time when the fulfillment updates are issued, used to prevent
* out-of-order updates on fulfillment information. If not provided, the
* internal system time will be used.
*/
// const addTime = {}
/**
* If set to true, and the Product google.cloud.retail.v2.Product is not
* found, the fulfillment information will still be processed and retained for
* at most 1 day and processed once the
* Product google.cloud.retail.v2.Product is created. If set to false, a
* NOT_FOUND error is returned if the
* Product google.cloud.retail.v2.Product is not found.
*/
// const allowMissing = true
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callAddFulfillmentPlaces() {
// Construct request
const request = {
product,
type,
placeIds,
};
// Run request
const [operation] = await retailClient.addFulfillmentPlaces(request);
const [response] = await operation.promise();
console.log(response);
}
callAddFulfillmentPlaces();
// [END retail_v2_generated_ProductService_AddFulfillmentPlaces_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(product, localInventories) {
// [START retail_v2_generated_ProductService_AddLocalInventories_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full resource name of Product google.cloud.retail.v2.Product,
* such as
* `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`.
* If the caller does not have permission to access the
* Product google.cloud.retail.v2.Product, regardless of whether or not it
* exists, a PERMISSION_DENIED error is returned.
*/
// const product = 'abc123'
/**
* Required. A list of inventory information at difference places. Each place
* is identified by its place ID. At most 3000 inventories are allowed per
* request.
*/
// const localInventories = 1234
/**
* Indicates which inventory fields in the provided list of
* LocalInventory google.cloud.retail.v2.LocalInventory to update. The
* field is updated to the provided value.
* If a field is set while the place does not have a previous local inventory,
* the local inventory at that store is created.
* If a field is set while the value of that field is not provided, the
* original field value, if it exists, is deleted.
* If the mask is not set or set with empty paths, all inventory fields will
* be updated.
* If an unsupported or unknown field is provided, an INVALID_ARGUMENT error
* is returned and the entire update will be ignored.
*/
// const addMask = {}
/**
* The time when the inventory updates are issued. Used to prevent
* out-of-order updates on local inventory fields. If not provided, the
* internal system time will be used.
*/
// const addTime = {}
/**
* If set to true, and the Product google.cloud.retail.v2.Product is not
* found, the local inventory will still be processed and retained for at most
* 1 day and processed once the Product google.cloud.retail.v2.Product is
* created. If set to false, a NOT_FOUND error is returned if the
* Product google.cloud.retail.v2.Product is not found.
*/
// const allowMissing = true
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callAddLocalInventories() {
// Construct request
const request = {
product,
localInventories,
};
// Run request
const [operation] = await retailClient.addLocalInventories(request);
const [response] = await operation.promise();
console.log(response);
}
callAddLocalInventories();
// [END retail_v2_generated_ProductService_AddLocalInventories_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent, product, productId) {
// [START retail_v2_generated_ProductService_CreateProduct_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The parent catalog resource name, such as
* `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`.
*/
// const parent = 'abc123'
/**
* Required. The Product google.cloud.retail.v2.Product to create.
*/
// const product = {}
/**
* Required. The ID to use for the Product google.cloud.retail.v2.Product,
* which will become the final component of the
* Product.name google.cloud.retail.v2.Product.name.
* If the caller does not have permission to create the
* Product google.cloud.retail.v2.Product, regardless of whether or not it
* exists, a PERMISSION_DENIED error is returned.
* This field must be unique among all
* Product google.cloud.retail.v2.Product s with the same
* parent google.cloud.retail.v2.CreateProductRequest.parent. Otherwise, an
* ALREADY_EXISTS error is returned.
* This field must be a UTF-8 encoded string with a length limit of 128
* characters. Otherwise, an INVALID_ARGUMENT error is returned.
*/
// const productId = 'abc123'
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callCreateProduct() {
// Construct request
const request = {
parent,
product,
productId,
};
// Run request
const response = await retailClient.createProduct(request);
console.log(response);
}
callCreateProduct();
// [END retail_v2_generated_ProductService_CreateProduct_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(name) {
// [START retail_v2_generated_ProductService_DeleteProduct_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full resource name of Product google.cloud.retail.v2.Product,
* such as
* `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`.
* If the caller does not have permission to delete the
* Product google.cloud.retail.v2.Product, regardless of whether or not it
* exists, a PERMISSION_DENIED error is returned.
* If the Product google.cloud.retail.v2.Product to delete does not exist,
* a NOT_FOUND error is returned.
* The Product google.cloud.retail.v2.Product to delete can neither be a
* Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION
* Product google.cloud.retail.v2.Product member nor a
* Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY
* Product google.cloud.retail.v2.Product with more than one
* variants google.cloud.retail.v2.Product.Type.VARIANT. Otherwise, an
* INVALID_ARGUMENT error is returned.
* All inventory information for the named
* Product google.cloud.retail.v2.Product will be deleted.
*/
// const name = 'abc123'
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callDeleteProduct() {
// Construct request
const request = {
name,
};
// Run request
const response = await retailClient.deleteProduct(request);
console.log(response);
}
callDeleteProduct();
// [END retail_v2_generated_ProductService_DeleteProduct_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(name) {
// [START retail_v2_generated_ProductService_GetProduct_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full resource name of Product google.cloud.retail.v2.Product,
* such as
* `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`.
* If the caller does not have permission to access the
* Product google.cloud.retail.v2.Product, regardless of whether or not it
* exists, a PERMISSION_DENIED error is returned.
* If the requested Product google.cloud.retail.v2.Product does not exist,
* a NOT_FOUND error is returned.
*/
// const name = 'abc123'
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callGetProduct() {
// Construct request
const request = {
name,
};
// Run request
const response = await retailClient.getProduct(request);
console.log(response);
}
callGetProduct();
// [END retail_v2_generated_ProductService_GetProduct_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent, inputConfig) {
// [START retail_v2_generated_ProductService_ImportProducts_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required.
* `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch`
* If no updateMask is specified, requires products.create permission.
* If updateMask is specified, requires products.update permission.
*/
// const parent = 'abc123'
/**
* Required. The desired input location of the data.
*/
// const inputConfig = {}
/**
* The desired location of errors incurred during the Import.
*/
// const errorsConfig = {}
/**
* Indicates which fields in the provided imported `products` to update. If
* not set, all fields are updated.
*/
// const updateMask = {}
/**
* The mode of reconciliation between existing products and the products to be
* imported. Defaults to
* ReconciliationMode.INCREMENTAL google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL.
*/
// const reconciliationMode = {}
/**
* Full Pub/Sub topic name for receiving notification. If this field is set,
* when the import is finished, a notification is sent to
* specified Pub/Sub topic. The message data is JSON string of a
* Operation google.longrunning.Operation.
* Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has
* to be within the same project as
* ImportProductsRequest.parent google.cloud.retail.v2.ImportProductsRequest.parent.
* Make sure that `service-<project
* number>@gcp-sa-retail.iam.gserviceaccount.com` has the
* `pubsub.topics.publish` IAM permission on the topic.
*/
// const notificationPubsubTopic = 'abc123'
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callImportProducts() {
// Construct request
const request = {
parent,
inputConfig,
};
// Run request
const [operation] = await retailClient.importProducts(request);
const [response] = await operation.promise();
console.log(response);
}
callImportProducts();
// [END retail_v2_generated_ProductService_ImportProducts_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent) {
// [START retail_v2_generated_ProductService_ListProducts_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The parent branch resource name, such as
* `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use
* `default_branch` as the branch ID, to list products under the default
* branch.
* If the caller does not have permission to list
* Product google.cloud.retail.v2.Product s under this branch, regardless of
* whether or not this branch exists, a PERMISSION_DENIED error is returned.
*/
// const parent = 'abc123'
/**
* Maximum number of Product google.cloud.retail.v2.Product s to return. If
* unspecified, defaults to 100. The maximum allowed value is 1000. Values
* above 1000 will be coerced to 1000.
* If this field is negative, an INVALID_ARGUMENT error is returned.
*/
// const pageSize = 1234
/**
* A page token
* ListProductsResponse.next_page_token google.cloud.retail.v2.ListProductsResponse.next_page_token,
* received from a previous
* ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts
* call. Provide this to retrieve the subsequent page.
* When paginating, all other parameters provided to
* ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts
* must match the call that provided the page token. Otherwise, an
* INVALID_ARGUMENT error is returned.
*/
// const pageToken = 'abc123'
/**
* A filter to apply on the list results. Supported features:
* * List all the products under the parent branch if
* filter google.cloud.retail.v2.ListProductsRequest.filter is unset.
* * List Product.Type.VARIANT google.cloud.retail.v2.Product.Type.VARIANT
* Product google.cloud.retail.v2.Product s sharing the same
* Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY
* Product google.cloud.retail.v2.Product. For example:
* `primary_product_id = "some_product_id"`
* * List Product google.cloud.retail.v2.Product s bundled in a
* Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION
* Product google.cloud.retail.v2.Product.
* For example:
* `collection_product_id = "some_product_id"`
* * List Product google.cloud.retail.v2.Product s with a partibular type.
* For example:
* `type = "PRIMARY"`
* `type = "VARIANT"`
* `type = "COLLECTION"`
* If the field is unrecognizable, an INVALID_ARGUMENT error is returned.
* If the specified
* Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY
* Product google.cloud.retail.v2.Product or
* Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION
* Product google.cloud.retail.v2.Product does not exist, a NOT_FOUND error
* is returned.
*/
// const filter = 'abc123'
/**
* The fields of Product google.cloud.retail.v2.Product to return in the
* responses. If not set or empty, the following fields are returned:
* * Product.name google.cloud.retail.v2.Product.name
* * Product.id google.cloud.retail.v2.Product.id
* * Product.title google.cloud.retail.v2.Product.title
* * Product.uri google.cloud.retail.v2.Product.uri
* * Product.images google.cloud.retail.v2.Product.images
* * Product.price_info google.cloud.retail.v2.Product.price_info
* * Product.brands google.cloud.retail.v2.Product.brands
* If "*" is provided, all fields are returned.
* Product.name google.cloud.retail.v2.Product.name is always returned no
* matter what mask is set.
* If an unsupported or unknown field is provided, an INVALID_ARGUMENT error
* is returned.
*/
// const readMask = {}
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callListProducts() {
// Construct request
const request = {
parent,
};
// Run request
const iterable = await retailClient.listProductsAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListProducts();
// [END retail_v2_generated_ProductService_ListProducts_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(product, type, placeIds) {
// [START retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full resource name of Product google.cloud.retail.v2.Product,
* such as
* `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`.
* If the caller does not have permission to access the
* Product google.cloud.retail.v2.Product, regardless of whether or not it
* exists, a PERMISSION_DENIED error is returned.
*/
// const product = 'abc123'
/**
* Required. The fulfillment type, including commonly used types (such as
* pickup in store and same day delivery), and custom types.
* Supported values:
* * "pickup-in-store"
* * "ship-to-store"
* * "same-day-delivery"
* * "next-day-delivery"
* * "custom-type-1"
* * "custom-type-2"
* * "custom-type-3"
* * "custom-type-4"
* * "custom-type-5"
* If this field is set to an invalid value other than these, an
* INVALID_ARGUMENT error is returned.
* This field directly corresponds to
* Product.fulfillment_info.type google.cloud.retail.v2.FulfillmentInfo.type.
*/
// const type = 'abc123'
/**
* Required. The IDs for this
* type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type, such as
* the store IDs for "pickup-in-store" or the region IDs for
* "same-day-delivery", to be removed for this
* type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type.
* At least 1 value is required, and a maximum of 2000 values are allowed.
* Each value must be a string with a length limit of 10 characters, matching
* the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an
* INVALID_ARGUMENT error is returned.
*/
// const placeIds = 'abc123'
/**
* The time when the fulfillment updates are issued, used to prevent
* out-of-order updates on fulfillment information. If not provided, the
* internal system time will be used.
*/
// const removeTime = {}
/**
* If set to true, and the Product google.cloud.retail.v2.Product is not
* found, the fulfillment information will still be processed and retained for
* at most 1 day and processed once the
* Product google.cloud.retail.v2.Product is created. If set to false, a
* NOT_FOUND error is returned if the
* Product google.cloud.retail.v2.Product is not found.
*/
// const allowMissing = true
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callRemoveFulfillmentPlaces() {
// Construct request
const request = {
product,
type,
placeIds,
};
// Run request
const [operation] = await retailClient.removeFulfillmentPlaces(request);
const [response] = await operation.promise();
console.log(response);
}
callRemoveFulfillmentPlaces();
// [END retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(product, placeIds) {
// [START retail_v2_generated_ProductService_RemoveLocalInventories_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full resource name of Product google.cloud.retail.v2.Product,
* such as
* `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`.
* If the caller does not have permission to access the
* Product google.cloud.retail.v2.Product, regardless of whether or not it
* exists, a PERMISSION_DENIED error is returned.
*/
// const product = 'abc123'
/**
* Required. A list of place IDs to have their inventory deleted.
* At most 3000 place IDs are allowed per request.
*/
// const placeIds = 'abc123'
/**
* The time when the inventory deletions are issued. Used to prevent
* out-of-order updates and deletions on local inventory fields. If not
* provided, the internal system time will be used.
*/
// const removeTime = {}
/**
* If set to true, and the Product google.cloud.retail.v2.Product is not
* found, the local inventory removal request will still be processed and
* retained for at most 1 day and processed once the
* Product google.cloud.retail.v2.Product is created. If set to false, a
* NOT_FOUND error is returned if the
* Product google.cloud.retail.v2.Product is not found.
*/
// const allowMissing = true
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callRemoveLocalInventories() {
// Construct request
const request = {
product,
placeIds,
};
// Run request
const [operation] = await retailClient.removeLocalInventories(request);
const [response] = await operation.promise();
console.log(response);
}
callRemoveLocalInventories();
// [END retail_v2_generated_ProductService_RemoveLocalInventories_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(inventory) {
// [START retail_v2_generated_ProductService_SetInventory_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The inventory information to update. The allowable fields to
* update are:
* * Product.price_info google.cloud.retail.v2.Product.price_info
* * Product.availability google.cloud.retail.v2.Product.availability
* * Product.available_quantity google.cloud.retail.v2.Product.available_quantity
* * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info
* The updated inventory fields must be specified in
* SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask.
* If
* SetInventoryRequest.inventory.name google.cloud.retail.v2.Product.name
* is empty or invalid, an INVALID_ARGUMENT error is returned.
* If the caller does not have permission to update the
* Product google.cloud.retail.v2.Product named in
* Product.name google.cloud.retail.v2.Product.name, regardless of whether
* or not it exists, a PERMISSION_DENIED error is returned.
* If the Product google.cloud.retail.v2.Product to update does not have
* existing inventory information, the provided inventory information will be
* inserted.
* If the Product google.cloud.retail.v2.Product to update has existing
* inventory information, the provided inventory information will be merged
* while respecting the last update time for each inventory field, using the
* provided or default value for
* SetInventoryRequest.set_time google.cloud.retail.v2.SetInventoryRequest.set_time.
* The caller can replace place IDs for a subset of fulfillment types in the
* following ways:
* * Adds "fulfillment_info" in
* SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask
* * Specifies only the desired fulfillment types and corresponding place IDs
* to update in
* SetInventoryRequest.inventory.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info
* The caller can clear all place IDs from a subset of fulfillment types in
* the following ways:
* * Adds "fulfillment_info" in
* SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask
* * Specifies only the desired fulfillment types to clear in
* SetInventoryRequest.inventory.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info
* * Checks that only the desired fulfillment info types have empty
* SetInventoryRequest.inventory.fulfillment_info.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids
* The last update time is recorded for the following inventory fields:
* * Product.price_info google.cloud.retail.v2.Product.price_info
* * Product.availability google.cloud.retail.v2.Product.availability
* * Product.available_quantity google.cloud.retail.v2.Product.available_quantity
* * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info
* If a full overwrite of inventory information while ignoring timestamps is
* needed,
* ProductService.UpdateProduct google.cloud.retail.v2.ProductService.UpdateProduct
* should be invoked instead.
*/
// const inventory = {}
/**
* Indicates which inventory fields in the provided
* Product google.cloud.retail.v2.Product to update.
* At least one field must be provided.
* If an unsupported or unknown field is provided, an INVALID_ARGUMENT error
* is returned and the entire update will be ignored.
*/
// const setMask = {}
/**
* The time when the request is issued, used to prevent
* out-of-order updates on inventory fields with the last update time
* recorded. If not provided, the internal system time will be used.
*/
// const setTime = {}
/**
* If set to true, and the Product google.cloud.retail.v2.Product with name
* Product.name google.cloud.retail.v2.Product.name is not found, the
* inventory update will still be processed and retained for at most 1 day
* until the Product google.cloud.retail.v2.Product is created. If set to
* false, a NOT_FOUND error is returned if the
* Product google.cloud.retail.v2.Product is not found.
*/
// const allowMissing = true
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callSetInventory() {
// Construct request
const request = {
inventory,
};
// Run request
const [operation] = await retailClient.setInventory(request);
const [response] = await operation.promise();
console.log(response);
}
callSetInventory();
// [END retail_v2_generated_ProductService_SetInventory_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(product) {
// [START retail_v2_generated_ProductService_UpdateProduct_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The product to update/create.
* If the caller does not have permission to update the
* Product google.cloud.retail.v2.Product, regardless of whether or not it
* exists, a PERMISSION_DENIED error is returned.
* If the Product google.cloud.retail.v2.Product to update does not exist
* and
* allow_missing google.cloud.retail.v2.UpdateProductRequest.allow_missing
* is not set, a NOT_FOUND error is returned.
*/
// const product = {}
/**
* Indicates which fields in the provided
* Product google.cloud.retail.v2.Product to update. The immutable and
* output only fields are NOT supported. If not set, all supported fields (the
* fields that are neither immutable nor output only) are updated.
* If an unsupported or unknown field is provided, an INVALID_ARGUMENT error
* is returned.
* The attribute key can be updated by setting the mask path as
* "attributes.${key_name}". If a key name is present in the mask but not in
* the patching product from the request, this key will be deleted after the
* update.
*/
// const updateMask = {}
/**
* If set to true, and the Product google.cloud.retail.v2.Product is not
* found, a new Product google.cloud.retail.v2.Product will be created. In
* this situation, `update_mask` is ignored.
*/
// const allowMissing = true
// Imports the Retail library
const {ProductServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ProductServiceClient();
async function callUpdateProduct() {
// Construct request
const request = {
product,
};
// Run request
const response = await retailClient.updateProduct(request);
console.log(response);
}
callUpdateProduct();
// [END retail_v2_generated_ProductService_UpdateProduct_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
This diff is collapsed.
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(servingConfig, controlId) {
// [START retail_v2_generated_ServingConfigService_AddControl_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The source ServingConfig resource name . Format:
* projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}
*/
// const servingConfig = 'abc123'
/**
* Required. The id of the control to apply. Assumed to be in the same catalog
* as the serving config - if id is not found a NOT_FOUND error is returned.
*/
// const controlId = 'abc123'
// Imports the Retail library
const {ServingConfigServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ServingConfigServiceClient();
async function callAddControl() {
// Construct request
const request = {
servingConfig,
controlId,
};
// Run request
const response = await retailClient.addControl(request);
console.log(response);
}
callAddControl();
// [END retail_v2_generated_ServingConfigService_AddControl_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent, servingConfig, servingConfigId) {
// [START retail_v2_generated_ServingConfigService_CreateServingConfig_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Full resource name of parent. Format:
* `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}`
*/
// const parent = 'abc123'
/**
* Required. The ServingConfig to create.
*/
// const servingConfig = {}
/**
* Required. The ID to use for the ServingConfig, which will become the final
* component of the ServingConfig's resource name.
* This value should be 4-63 characters, and valid characters
* are /[a-z][0-9]-_/.
*/
// const servingConfigId = 'abc123'
// Imports the Retail library
const {ServingConfigServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ServingConfigServiceClient();
async function callCreateServingConfig() {
// Construct request
const request = {
parent,
servingConfig,
servingConfigId,
};
// Run request
const response = await retailClient.createServingConfig(request);
console.log(response);
}
callCreateServingConfig();
// [END retail_v2_generated_ServingConfigService_CreateServingConfig_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(name) {
// [START retail_v2_generated_ServingConfigService_DeleteServingConfig_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the ServingConfig to delete. Format:
* projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}
*/
// const name = 'abc123'
// Imports the Retail library
const {ServingConfigServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ServingConfigServiceClient();
async function callDeleteServingConfig() {
// Construct request
const request = {
name,
};
// Run request
const response = await retailClient.deleteServingConfig(request);
console.log(response);
}
callDeleteServingConfig();
// [END retail_v2_generated_ServingConfigService_DeleteServingConfig_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(name) {
// [START retail_v2_generated_ServingConfigService_GetServingConfig_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the ServingConfig to get. Format:
* projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}
*/
// const name = 'abc123'
// Imports the Retail library
const {ServingConfigServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ServingConfigServiceClient();
async function callGetServingConfig() {
// Construct request
const request = {
name,
};
// Run request
const response = await retailClient.getServingConfig(request);
console.log(response);
}
callGetServingConfig();
// [END retail_v2_generated_ServingConfigService_GetServingConfig_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent) {
// [START retail_v2_generated_ServingConfigService_ListServingConfigs_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The catalog resource name. Format:
* projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}
*/
// const parent = 'abc123'
/**
* Optional. Maximum number of results to return. If unspecified, defaults
* to 100. If a value greater than 100 is provided, at most 100 results are
* returned.
*/
// const pageSize = 1234
/**
* Optional. A page token, received from a previous `ListServingConfigs` call.
* Provide this to retrieve the subsequent page.
*/
// const pageToken = 'abc123'
// Imports the Retail library
const {ServingConfigServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ServingConfigServiceClient();
async function callListServingConfigs() {
// Construct request
const request = {
parent,
};
// Run request
const iterable = await retailClient.listServingConfigsAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListServingConfigs();
// [END retail_v2_generated_ServingConfigService_ListServingConfigs_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(servingConfig, controlId) {
// [START retail_v2_generated_ServingConfigService_RemoveControl_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The source ServingConfig resource name . Format:
* projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}
*/
// const servingConfig = 'abc123'
/**
* Required. The id of the control to apply. Assumed to be in the same catalog
* as the serving config.
*/
// const controlId = 'abc123'
// Imports the Retail library
const {ServingConfigServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ServingConfigServiceClient();
async function callRemoveControl() {
// Construct request
const request = {
servingConfig,
controlId,
};
// Run request
const response = await retailClient.removeControl(request);
console.log(response);
}
callRemoveControl();
// [END retail_v2_generated_ServingConfigService_RemoveControl_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(servingConfig) {
// [START retail_v2_generated_ServingConfigService_UpdateServingConfig_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The ServingConfig to update.
*/
// const servingConfig = {}
/**
* Indicates which fields in the provided
* ServingConfig google.cloud.retail.v2.ServingConfig to update. The
* following are NOT supported:
* * ServingConfig.name google.cloud.retail.v2.ServingConfig.name
* If not set, all supported fields are updated.
*/
// const updateMask = {}
// Imports the Retail library
const {ServingConfigServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new ServingConfigServiceClient();
async function callUpdateServingConfig() {
// Construct request
const request = {
servingConfig,
};
// Run request
const response = await retailClient.updateServingConfig(request);
console.log(response);
}
callUpdateServingConfig();
// [END retail_v2_generated_ServingConfigService_UpdateServingConfig_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent, userEvent) {
// [START retail_v2_generated_UserEventService_CollectUserEvent_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The parent catalog name, such as
* `projects/1234/locations/global/catalogs/default_catalog`.
*/
// const parent = 'abc123'
/**
* Required. URL encoded UserEvent proto with a length limit of 2,000,000
* characters.
*/
// const userEvent = 'abc123'
/**
* The URL including cgi-parameters but excluding the hash fragment with a
* length limit of 5,000 characters. This is often more useful than the
* referer URL, because many browsers only send the domain for 3rd party
* requests.
*/
// const uri = 'abc123'
/**
* The event timestamp in milliseconds. This prevents browser caching of
* otherwise identical get requests. The name is abbreviated to reduce the
* payload bytes.
*/
// const ets = 1234
// Imports the Retail library
const {UserEventServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new UserEventServiceClient();
async function callCollectUserEvent() {
// Construct request
const request = {
parent,
userEvent,
};
// Run request
const response = await retailClient.collectUserEvent(request);
console.log(response);
}
callCollectUserEvent();
// [END retail_v2_generated_UserEventService_CollectUserEvent_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent, inputConfig) {
// [START retail_v2_generated_UserEventService_ImportUserEvents_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. `projects/1234/locations/global/catalogs/default_catalog`
*/
// const parent = 'abc123'
/**
* Required. The desired input location of the data.
*/
// const inputConfig = {}
/**
* The desired location of errors incurred during the Import. Cannot be set
* for inline user event imports.
*/
// const errorsConfig = {}
// Imports the Retail library
const {UserEventServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new UserEventServiceClient();
async function callImportUserEvents() {
// Construct request
const request = {
parent,
inputConfig,
};
// Run request
const [operation] = await retailClient.importUserEvents(request);
const [response] = await operation.promise();
console.log(response);
}
callImportUserEvents();
// [END retail_v2_generated_UserEventService_ImportUserEvents_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent, filter) {
// [START retail_v2_generated_UserEventService_PurgeUserEvents_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the catalog under which the events are
* created. The format is
* `projects/${projectId}/locations/global/catalogs/${catalogId}`
*/
// const parent = 'abc123'
/**
* Required. The filter string to specify the events to be deleted with a
* length limit of 5,000 characters. Empty string filter is not allowed. The
* eligible fields for filtering are:
* * `eventType`: Double quoted
* UserEvent.event_type google.cloud.retail.v2.UserEvent.event_type string.
* * `eventTime`: in ISO 8601 "zulu" format.
* * `visitorId`: Double quoted string. Specifying this will delete all
* events associated with a visitor.
* * `userId`: Double quoted string. Specifying this will delete all events
* associated with a user.
* Examples:
* * Deleting all events in a time range:
* `eventTime > "2012-04-23T18:25:43.511Z"
* eventTime < "2012-04-23T18:30:43.511Z"`
* * Deleting specific eventType in time range:
* `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"`
* * Deleting all events for a specific visitor:
* `visitorId = "visitor1024"`
* The filtering fields are assumed to have an implicit AND.
*/
// const filter = 'abc123'
/**
* Actually perform the purge.
* If `force` is set to false, the method will return the expected purge count
* without deleting any user events.
*/
// const force = true
// Imports the Retail library
const {UserEventServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new UserEventServiceClient();
async function callPurgeUserEvents() {
// Construct request
const request = {
parent,
filter,
};
// Run request
const [operation] = await retailClient.purgeUserEvents(request);
const [response] = await operation.promise();
console.log(response);
}
callPurgeUserEvents();
// [END retail_v2_generated_UserEventService_PurgeUserEvents_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
// Copyright 2022 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.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent) {
// [START retail_v2_generated_UserEventService_RejoinUserEvents_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The parent catalog resource name, such as
* `projects/1234/locations/global/catalogs/default_catalog`.
*/
// const parent = 'abc123'
/**
* The type of the user event rejoin to define the scope and range of the user
* events to be rejoined with the latest product catalog. Defaults to
* USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an
* invalid integer value.
*/
// const userEventRejoinScope = {}
// Imports the Retail library
const {UserEventServiceClient} = require('@google-cloud/retail').v2;
// Instantiates a client
const retailClient = new UserEventServiceClient();
async function callRejoinUserEvents() {
// Construct request
const request = {
parent,
};
// Run request
const [operation] = await retailClient.rejoinUserEvents(request);
const [response] = await operation.promise();
console.log(response);
}
callRejoinUserEvents();
// [END retail_v2_generated_UserEventService_RejoinUserEvents_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment