Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
fix: remove gcloud_project env variable (#156)
Browse files Browse the repository at this point in the history
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
  • Loading branch information
nmykhailets and kweinmeister authored Mar 15, 2022
1 parent 27f7cc4 commit 16cefb4
Show file tree
Hide file tree
Showing 38 changed files with 260 additions and 228 deletions.
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/events/purge-user-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ async function main() {
const {UserEventServiceClient} = require('@google-cloud/retail').v2;
const utils = require('../setup/setup-cleanup');

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new UserEventServiceClient();

const projectId = await retailClient.getProjectId();
const visitorId = 'test_visitor_id';

// Placement
const parent = `projects/${projectNumber}/locations/global/catalogs/default_catalog`;
const parent = `projects/${projectId}/locations/global/catalogs/default_catalog`;

// The filter string to specify the events to be deleted with a
// length limit of 5,000 characters.
Expand All @@ -34,9 +37,6 @@ async function main() {
// Actually perform the purge.
const force = true;

// Instantiates a client.
const retailClient = new UserEventServiceClient();

const callPurgeUserEvents = async () => {
// Construct request
const request = {
Expand Down
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/events/rejoin-user-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ async function main() {
const {UserEventServiceClient} = require('@google-cloud/retail').v2;
const utils = require('../setup/setup-cleanup');

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new UserEventServiceClient();

const projectId = await retailClient.getProjectId();
const visitorId = 'test_visitor_id';

// Placement
const parent = `projects/${projectNumber}/locations/global/catalogs/default_catalog`; // TO CHECK ERROR HANDLING PASTE THE INVALID CATALOG NAME HERE
const parent = `projects/${projectId}/locations/global/catalogs/default_catalog`; // TO CHECK ERROR HANDLING PASTE THE INVALID CATALOG NAME HERE

const UserEventRejoinScope = {
USER_EVENT_REJOIN_SCOPE_UNSPECIFIED: 0,
Expand All @@ -36,9 +39,6 @@ async function main() {
// events to be rejoined with the latest product catalog
const userEventRejoinScope = UserEventRejoinScope.UNJOINED_EVENTS;

// Instantiates a client.
const retailClient = new UserEventServiceClient();

const callRejoinUserEvents = async () => {
// Construct request
const request = {
Expand Down
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/events/write-user-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ async function main() {
const {UserEventServiceClient} = require('@google-cloud/retail').v2;
const utils = require('../setup/setup-cleanup');

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new UserEventServiceClient();

const projectId = await retailClient.getProjectId();
const visitorId = 'test_visitor_id';

// Placement
const parent = `projects/${projectNumber}/locations/global/catalogs/default_catalog`; // TO CHECK ERROR HANDLING PASTE THE INVALID CATALOG NAME HERE
const parent = `projects/${projectId}/locations/global/catalogs/default_catalog`; // TO CHECK ERROR HANDLING PASTE THE INVALID CATALOG NAME HERE

// User event to write
const userEvent = {
Expand All @@ -36,9 +39,6 @@ async function main() {
},
};

// Instantiates a client.
const retailClient = new UserEventServiceClient();

const callWriteUserEvent = async () => {
// Construct request
const request = {
Expand Down
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/product/add-fulfillment-places.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ async function main(generatedProductId) {
const {ProductServiceClient} = require('@google-cloud/retail').v2;
const utils = require('../setup/setup-cleanup');

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

// Create product
const createdProduct = await utils.createProduct(
projectNumber,
projectId,
generatedProductId
);

Expand All @@ -50,9 +53,6 @@ async function main(generatedProductId) {
// at most 1 day and processed once the product is created
const allowMissing = true;

// Instantiates a client.
const retailClient = new ProductServiceClient();

const calladdFulfillmentPlaces = async () => {
// Construct request
const request = {
Expand Down
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/product/create-product.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ async function main(generatedProductId) {
const {ProductServiceClient} = require('@google-cloud/retail').v2;
const utils = require('../setup/setup-cleanup');

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

// The parent catalog resource name
const parent = `projects/${projectNumber}/locations/global/catalogs/default_catalog/branches/default_branch`;
const parent = `projects/${projectId}/locations/global/catalogs/default_catalog/branches/default_branch`;

// The ID to use for the product
const productId = generatedProductId
Expand All @@ -45,9 +48,6 @@ async function main(generatedProductId) {
availability: 'IN_STOCK',
};

// Instantiates a client.
const retailClient = new ProductServiceClient();

const callCreateProduct = async () => {
// Construct request
const request = {
Expand Down
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/product/crud-product.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ async function main(generatedProductId) {
// Imports the Google Cloud client library.
const {ProductServiceClient} = require('@google-cloud/retail').v2;

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

// The parent catalog resource name
const parent = `projects/${projectNumber}/locations/global/catalogs/default_catalog/branches/default_branch`;
const parent = `projects/${projectId}/locations/global/catalogs/default_catalog/branches/default_branch`;

// The ID to use for the product
const productId = generatedProductId
Expand Down Expand Up @@ -63,9 +66,6 @@ async function main(generatedProductId) {
availability: 'OUT_OF_STOCK',
};

// Instantiates a client.
const retailClient = new ProductServiceClient();

const callCreateProduct = async () => {
// Construct request
const request = {
Expand Down
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/product/delete-product.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ async function main(generatedProductId) {
const {ProductServiceClient} = require('@google-cloud/retail').v2;
const utils = require('../setup/setup-cleanup');

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

// Create product
const product = await utils.createProduct(projectNumber, generatedProductId);
const product = await utils.createProduct(projectId, generatedProductId);

// Full resource name of Product
const name = product.name;

// Instantiates a client.
const retailClient = new ProductServiceClient();

const callDeleteProduct = async () => {
// Construct request
const request = {
Expand Down
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/product/get-product.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ async function main(generatedProductId) {
const {ProductServiceClient} = require('@google-cloud/retail').v2;
const utils = require('../setup/setup-cleanup');

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

// Create product
const product = await utils.createProduct(projectNumber, generatedProductId);
const product = await utils.createProduct(projectId, generatedProductId);

// Full resource name of Product
const name = product.name;

// Instantiates a client.
const retailClient = new ProductServiceClient();

const callGetProduct = async () => {
// Construct request
const request = {
Expand Down
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/product/get-products-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ async function main() {
// Imports the Google Cloud client library.
const {ProductServiceClient} = require('@google-cloud/retail').v2;

const projectNumber = process.env['GCLOUD_PROJECT'];

// Placement
const parent = `projects/${projectNumber}/locations/global/catalogs/default_catalog/branches/default_branch`;

// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

// Placement
const parent = `projects/${projectId}/locations/global/catalogs/default_catalog/branches/default_branch`;

async function callListProducts() {
console.log('Start get products list');
// Construct request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ async function main() {
// Imports the Google Cloud client library.
const {ProductServiceClient} = require('@google-cloud/retail').v2;

const projectNumber = process.env['GCLOUD_PROJECT'];
const projectId = process.env['PROJECT_ID'];
// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

const datasetId = 'products';
const tableId = 'products'; // TO CHECK ERROR HANDLING USE THE TABLE WITH INVALID PRODUCTS
const dataSchema = 'product';

// Placement
const parent = `projects/${projectNumber}/locations/global/catalogs/default_catalog/branches/default_branch`; // TO CHECK ERROR HANDLING PASTE THE INVALID CATALOG NAME HERE
const parent = `projects/${projectId}/locations/global/catalogs/default_catalog/branches/default_branch`; // TO CHECK ERROR HANDLING PASTE THE INVALID CATALOG NAME HERE

// The desired input location of the data.
const inputConfig = {
Expand All @@ -55,9 +57,6 @@ async function main() {
// The mode of reconciliation between existing products and the products to be imported.
const reconciliationMode = reconciliationModes.INCREMENTAL;

// Instantiates a client.
const retailClient = new ProductServiceClient();

const callImportProducts = async () => {
// Construct request
const request = {
Expand Down
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/product/import-products-gcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ async function main(bucketName) {
// Imports the Google Cloud client library.
const {ProductServiceClient} = require('@google-cloud/retail').v2;

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

const gcsBucket = `gs://${bucketName}`;
const gcsErrorsBucket = `gs://${bucketName}/error`;
const gcsProductsObject = 'products.json'; // TO CHECK ERROR HANDLING USE THE JSON WITH INVALID PRODUCT

// Placement
const parent = `projects/${projectNumber}/locations/global/catalogs/default_catalog/branches/default_branch`; //TO CHECK ERROR HANDLING PASTE THE INVALID CATALOG NAME HERE
const parent = `projects/${projectId}/locations/global/catalogs/default_catalog/branches/default_branch`; //TO CHECK ERROR HANDLING PASTE THE INVALID CATALOG NAME HERE

// The desired input location of the data.
const inputConfig = {
Expand All @@ -48,9 +51,6 @@ async function main(bucketName) {
IOperation: 2,
};

// Instantiates a client.
const retailClient = new ProductServiceClient();

const callImportProducts = async () => {
// Construct request
const request = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ async function main(id1, id2) {
const {ProductServiceClient} = require('@google-cloud/retail').v2;
const utils = require('../setup/setup-cleanup');

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

// Placement
const parent = `projects/${projectNumber}/locations/global/catalogs/default_catalog/branches/default_branch`;
const parent = `projects/${projectId}/locations/global/catalogs/default_catalog/branches/default_branch`;

const product1 = {
id: id1 ? id1 : Math.random().toString(36).slice(2).toUpperCase(),
Expand Down Expand Up @@ -89,9 +92,6 @@ async function main(id1, id2) {
IOperation: 2,
};

// Instantiates a client.
const retailClient = new ProductServiceClient();

const callImportProducts = async () => {
// Construct request
const request = {
Expand All @@ -118,7 +118,7 @@ async function main(id1, id2) {
console.log('Import products finished');

// Delete imported products
await utils.deleteProductsByIds(projectNumber, [product1.id, product2.id]);
await utils.deleteProductsByIds(projectId, [product1.id, product2.id]);
console.log('Products deleted');
// [END retail_import_products_from_inline_source]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ async function main(generatedProductId) {
const {ProductServiceClient} = require('@google-cloud/retail').v2;
const utils = require('../setup/setup-cleanup');

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

// Create product
const createdProduct = await utils.createProduct(
projectNumber,
projectId,
generatedProductId,
true
);
Expand All @@ -47,9 +50,6 @@ async function main(generatedProductId) {
seconds: Math.round(Date.now() / 1000),
};

// Instantiates a client.
const retailClient = new ProductServiceClient();

const callRemoveFulfillmentPlaces = async () => {
// Construct request
const request = {
Expand Down
10 changes: 5 additions & 5 deletions samples/interactive-tutorials/product/set-inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ async function main(generatedProductId) {
const {ProductServiceClient} = require('@google-cloud/retail').v2;
const utils = require('../setup/setup-cleanup');

const projectNumber = process.env['GCLOUD_PROJECT'];
// Instantiates a client.
const retailClient = new ProductServiceClient();

const projectId = await retailClient.getProjectId();

// Create product
const createdProduct = await utils.createProduct(
projectNumber,
projectId,
generatedProductId
);

Expand Down Expand Up @@ -61,9 +64,6 @@ async function main(generatedProductId) {
// inventory update will still be processed and retained for at most 1 day until the product is created
const allowMissing = true;

// Instantiates a client.
const retailClient = new ProductServiceClient();

const callSetInventory = async () => {
// Construct request
const request = {
Expand Down
Loading

0 comments on commit 16cefb4

Please sign in to comment.