From 1903a7e8c2687b21f9ba144b6519ed2ce0c0c6fa Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Sat, 17 Jun 2023 00:05:17 +0000 Subject: [PATCH 1/2] feat: support extractive content in search feat: add redirected uri in search response feat: support docx/pptx/txt/csv in allowed data format docs: keep the API doc up-to-date with recent changes PiperOrigin-RevId: 541013898 Source-Link: https://github.com/googleapis/googleapis/commit/e491475a0207826f4246e4a69800df84e797d10d Source-Link: https://github.com/googleapis/googleapis-gen/commit/2bfb35702b702b338c02b3daea5af58a871c44eb Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRpc2NvdmVyeWVuZ2luZS8uT3dsQm90LnlhbWwiLCJoIjoiMmJmYjM1NzAyYjcwMmIzMzhjMDJiM2RhZWE1YWY1OGE4NzFjNDRlYiJ9 --- .../v1/.eslintignore | 7 + .../v1/.eslintrc.json | 3 + .../v1/.gitignore | 14 + .../google-cloud-discoveryengine/v1/.jsdoc.js | 55 + .../v1/.mocharc.js | 33 + .../v1/.prettierrc.js | 22 + .../google-cloud-discoveryengine/v1/README.md | 1 + .../v1/linkinator.config.json | 16 + .../v1/package.json | 68 + .../cloud/discoveryengine/v1/common.proto | 100 + .../v1/completion_service.proto | 116 ++ .../cloud/discoveryengine/v1/document.proto | 118 ++ .../discoveryengine/v1/document_service.proto | 313 +++ .../discoveryengine/v1/import_config.proto | 334 +++ .../discoveryengine/v1/purge_config.proto | 86 + .../cloud/discoveryengine/v1/schema.proto | 58 + .../discoveryengine/v1/schema_service.proto | 256 +++ .../discoveryengine/v1/search_service.proto | 289 +++ .../cloud/discoveryengine/v1/user_event.proto | 458 ++++ .../v1/user_event_service.proto | 133 ++ .../v1/completion_service.complete_query.js | 99 + .../v1/document_service.create_document.js | 86 + .../v1/document_service.delete_document.js | 68 + .../v1/document_service.get_document.js | 68 + .../v1/document_service.import_documents.js | 133 ++ .../v1/document_service.list_documents.js | 88 + .../v1/document_service.purge_documents.js | 75 + .../v1/document_service.update_document.js | 74 + .../v1/schema_service.create_schema.js | 79 + .../v1/schema_service.delete_schema.js | 63 + .../generated/v1/schema_service.get_schema.js | 62 + .../v1/schema_service.list_schemas.js | 81 + .../v1/schema_service.update_schema.js | 68 + .../generated/v1/search_service.search.js | 172 ++ ...adata.google.cloud.discoveryengine.v1.json | 867 ++++++++ .../user_event_service.collect_user_event.js | 81 + .../user_event_service.import_user_events.js | 83 + .../v1/user_event_service.write_user_event.js | 67 + .../v1/src/index.ts | 33 + .../v1/src/v1/completion_service_client.ts | 854 ++++++++ .../v1/completion_service_client_config.json | 43 + .../src/v1/completion_service_proto_list.json | 13 + .../v1/src/v1/document_service_client.ts | 1839 ++++++++++++++++ .../v1/document_service_client_config.json | 82 + .../src/v1/document_service_proto_list.json | 13 + .../v1/src/v1/gapic_metadata.json | 261 +++ .../v1/src/v1/index.ts | 23 + .../v1/src/v1/schema_service_client.ts | 1550 ++++++++++++++ .../src/v1/schema_service_client_config.json | 63 + .../v1/src/v1/schema_service_proto_list.json | 13 + .../v1/src/v1/search_service_client.ts | 1367 ++++++++++++ .../src/v1/search_service_client_config.json | 43 + .../v1/src/v1/search_service_proto_list.json | 13 + .../v1/src/v1/user_event_service_client.ts | 1220 +++++++++++ .../v1/user_event_service_client_config.json | 62 + .../src/v1/user_event_service_proto_list.json | 13 + .../system-test/fixtures/sample/src/index.js | 31 + .../system-test/fixtures/sample/src/index.ts | 56 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_completion_service_v1.ts | 609 ++++++ .../v1/test/gapic_document_service_v1.ts | 1824 ++++++++++++++++ .../v1/test/gapic_schema_service_v1.ts | 1638 +++++++++++++++ .../v1/test/gapic_search_service_v1.ts | 925 +++++++++ .../v1/test/gapic_user_event_service_v1.ts | 1162 +++++++++++ .../v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1beta/.eslintignore | 7 + .../v1beta/.eslintrc.json | 3 + .../v1beta/.gitignore | 14 + .../v1beta/.jsdoc.js | 55 + .../v1beta/.mocharc.js | 33 + .../v1beta/.prettierrc.js | 22 + .../v1beta/README.md | 1 + .../v1beta/linkinator.config.json | 16 + .../v1beta/package.json | 69 + .../cloud/discoveryengine/v1beta/common.proto | 129 ++ .../v1beta/completion_service.proto | 118 ++ .../discoveryengine/v1beta/document.proto | 123 ++ .../v1beta/document_service.proto | 316 +++ .../v1beta/import_config.proto | 342 +++ .../discoveryengine/v1beta/purge_config.proto | 86 + .../v1beta/recommendation_service.proto | 206 ++ .../cloud/discoveryengine/v1beta/schema.proto | 58 + .../v1beta/schema_service.proto | 259 +++ .../v1beta/search_service.proto | 617 ++++++ .../discoveryengine/v1beta/user_event.proto | 465 +++++ .../v1beta/user_event_service.proto | 133 ++ .../completion_service.complete_query.js | 101 + .../document_service.create_document.js | 86 + .../document_service.delete_document.js | 68 + .../v1beta/document_service.get_document.js | 68 + .../document_service.import_documents.js | 136 ++ .../v1beta/document_service.list_documents.js | 88 + .../document_service.purge_documents.js | 75 + .../document_service.update_document.js | 75 + .../recommendation_service.recommend.js | 157 ++ .../v1beta/schema_service.create_schema.js | 80 + .../v1beta/schema_service.delete_schema.js | 63 + .../v1beta/schema_service.get_schema.js | 62 + .../v1beta/schema_service.list_schemas.js | 81 + .../v1beta/schema_service.update_schema.js | 70 + .../generated/v1beta/search_service.search.js | 197 ++ ...a.google.cloud.discoveryengine.v1beta.json | 947 +++++++++ .../user_event_service.collect_user_event.js | 81 + .../user_event_service.import_user_events.js | 80 + .../user_event_service.write_user_event.js | 67 + .../v1beta/src/index.ts | 35 + .../src/v1beta/completion_service_client.ts | 856 ++++++++ .../completion_service_client_config.json | 43 + .../v1beta/completion_service_proto_list.json | 14 + .../src/v1beta/document_service_client.ts | 1845 +++++++++++++++++ .../document_service_client_config.json | 82 + .../v1beta/document_service_proto_list.json | 14 + .../v1beta/src/v1beta/gapic_metadata.json | 285 +++ .../v1beta/src/v1beta/index.ts | 24 + .../v1beta/recommendation_service_client.ts | 937 +++++++++ .../recommendation_service_client_config.json | 43 + .../recommendation_service_proto_list.json | 14 + .../src/v1beta/schema_service_client.ts | 1553 ++++++++++++++ .../v1beta/schema_service_client_config.json | 63 + .../src/v1beta/schema_service_proto_list.json | 14 + .../src/v1beta/search_service_client.ts | 1427 +++++++++++++ .../v1beta/search_service_client_config.json | 43 + .../src/v1beta/search_service_proto_list.json | 14 + .../src/v1beta/user_event_service_client.ts | 1220 +++++++++++ .../user_event_service_client_config.json | 62 + .../v1beta/user_event_service_proto_list.json | 14 + .../system-test/fixtures/sample/src/index.js | 32 + .../system-test/fixtures/sample/src/index.ts | 62 + .../v1beta/system-test/install.ts | 49 + .../test/gapic_completion_service_v1beta.ts | 609 ++++++ .../test/gapic_document_service_v1beta.ts | 1824 ++++++++++++++++ .../gapic_recommendation_service_v1beta.ts | 625 ++++++ .../test/gapic_schema_service_v1beta.ts | 1638 +++++++++++++++ .../test/gapic_search_service_v1beta.ts | 925 +++++++++ .../test/gapic_user_event_service_v1beta.ts | 1162 +++++++++++ .../v1beta/tsconfig.json | 19 + .../v1beta/webpack.config.js | 64 + 138 files changed, 39941 insertions(+) create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/README.md create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/package.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/common.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/completion_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/import_config.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/purge_config.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/search_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/completion_service.complete_query.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.create_document.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.delete_document.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.get_document.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.import_documents.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.list_documents.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.purge_documents.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.update_document.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.create_schema.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.delete_schema.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.get_schema.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.list_schemas.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.update_schema.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/search_service.search.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/snippet_metadata.google.cloud.discoveryengine.v1.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_completion_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_document_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_schema_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_search_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_user_event_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintignore create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.gitignore create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/README.md create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/package.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/common.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/completion_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/import_config.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/purge_config.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/search_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event_service.proto create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/completion_service.complete_query.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.create_document.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.delete_document.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.get_document.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.import_documents.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.list_documents.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.purge_documents.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.update_document.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/recommendation_service.recommend.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.create_schema.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.delete_schema.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.get_schema.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.list_schemas.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.update_schema.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/search_service.search.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/index.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/index.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_completion_service_v1beta.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_document_service_v1beta.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_recommendation_service_v1beta.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_schema_service_v1beta.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_search_service_v1beta.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_user_event_service_v1beta.ts create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/webpack.config.js diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintignore b/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintrc.json b/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.gitignore b/owl-bot-staging/google-cloud-discoveryengine/v1/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.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__ diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.jsdoc.js b/owl-bot-staging/google-cloud-discoveryengine/v1/.jsdoc.js new file mode 100644 index 00000000000..69c2c79afc4 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 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 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/discoveryengine', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.mocharc.js b/owl-bot-staging/google-cloud-discoveryengine/v1/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 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. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +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 diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.prettierrc.js b/owl-bot-staging/google-cloud-discoveryengine/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 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. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/README.md b/owl-bot-staging/google-cloud-discoveryengine/v1/README.md new file mode 100644 index 00000000000..3f2b1b5b595 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/README.md @@ -0,0 +1 @@ +Discoveryengine: Nodejs Client diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/linkinator.config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/package.json b/owl-bot-staging/google-cloud-discoveryengine/v1/package.json new file mode 100644 index 00000000000..63ead994003 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/package.json @@ -0,0 +1,68 @@ +{ + "name": "@google-cloud/discoveryengine", + "version": "0.1.0", + "description": "Discoveryengine client for Node.js", + "repository": "googleapis/nodejs-discoveryengine", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google discoveryengine", + "discoveryengine", + "completion service", + "document service", + "schema service", + "search service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/common.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/common.proto new file mode 100644 index 00000000000..b6f887c33cd --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/common.proto @@ -0,0 +1,100 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; +option (google.api.resource_definition) = { + type: "discoveryengine.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}" + pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}" +}; +option (google.api.resource_definition) = { + type: "discoveryengine.googleapis.com/DataStore" + pattern: "projects/{project}/locations/{location}/dataStores/{data_store}" + pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}" +}; +option (google.api.resource_definition) = { + type: "discoveryengine.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}" + pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}" +}; + +// A custom attribute that is not explicitly modeled in a resource, e.g. +// [UserEvent][google.cloud.discoveryengine.v1.UserEvent]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is + // returned. + // + // Exactly one of + // [CustomAttribute.text][google.cloud.discoveryengine.v1.CustomAttribute.text] + // or + // [CustomAttribute.numbers][google.cloud.discoveryengine.v1.CustomAttribute.numbers] + // should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of + // [CustomAttribute.text][google.cloud.discoveryengine.v1.CustomAttribute.text] + // or + // [CustomAttribute.numbers][google.cloud.discoveryengine.v1.CustomAttribute.numbers] + // should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + repeated double numbers = 2; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. Don't set for anonymous users. + // + // Always use a hashed value for this ID. + // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded + // model quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + string user_id = 1; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1.UserEventService.CollectUserEvent] + // or if + // [UserEvent.direct_user_request][google.cloud.discoveryengine.v1.UserEvent.direct_user_request] + // is set. + string user_agent = 2; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/completion_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/completion_service.proto new file mode 100644 index 00000000000..29ba6317dc1 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/completion_service.proto @@ -0,0 +1,116 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; + +// Service for Auto-Completion. +service CompletionService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified user input with keyword suggestions. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v1/{data_store=projects/*/locations/*/dataStores/*}:completeQuery" + additional_bindings { + get: "/v1/{data_store=projects/*/locations/*/collections/*/dataStores/*}:completeQuery" + } + }; + } +} + +// Request message for +// [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1.CompletionService.CompleteQuery] +// method. +message CompleteQueryRequest { + // Required. The parent data store resource name for which the completion is + // performed, such as + // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`. + string data_store = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // Required. The typeahead input used to fetch suggestions. Maximum length is + // 128 characters. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Selects data model of query suggestions for serving. Currently supported + // values: + // + // * `document` - Using suggestions generated from user-imported documents. + // * `search-history` - Using suggestions generated from the past history of + // [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] + // API calls. Do not use it when there is no traffic for Search API. + // * `user-event` - Using suggestions generated from user-imported search + // events. + // + // Default values: + // + // * `document` is the default model for regular dataStores. + // * `search-history` is the default model for + // [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1.IndustryVertical.SITE_SEARCH] + // dataStores. + string query_model = 3; + + // 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. + // + // This field should NOT have a fixed value such as `unknown_visitor`. + // + // This should be the same identifier as + // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id] + // and + // [SearchRequest.user_pseudo_id][google.cloud.discoveryengine.v1.SearchRequest.user_pseudo_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + string user_pseudo_id = 4; +} + +// Response message for +// [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1.CompletionService.CompleteQuery] +// method. +message CompleteQueryResponse { + // Suggestions as search queries. + message QuerySuggestion { + // The suggestion for the query. + string suggestion = 1; + } + + // Results of the matched query suggestions. The result list is ordered and + // the first result is a top suggestion. + repeated QuerySuggestion query_suggestions = 1; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document.proto new file mode 100644 index 00000000000..2935f206b8b --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document.proto @@ -0,0 +1,118 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; + +// Document captures all raw metadata information of items to be recommended or +// searched. +message Document { + option (google.api.resource) = { + type: "discoveryengine.googleapis.com/Document" + pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}" + pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}" + }; + + // Unstructured data linked to this document. + message Content { + oneof content { + // The content represented as a stream of bytes. The maximum length is + // 1,000,000 bytes (1 MB / ~0.95 MiB). + // + // Note: As with all `bytes` fields, this field is represented as pure + // binary in Protocol Buffers and base64-encoded string in JSON. For + // example, `abc123!?$*&()'-=@~` should be represented as + // `YWJjMTIzIT8kKiYoKSctPUB+` in JSON. See + // https://developers.google.com/protocol-buffers/docs/proto3#json. + bytes raw_bytes = 2; + + // The URI of the content. Only Cloud Storage URIs (e.g. + // `gs://bucket-name/path/to/file`) are supported. The maximum file size + // is 100 MB. + string uri = 3; + } + + // The MIME type of the content. Supported types: + // + // * `application/pdf` (PDF) + // * `text/html` (HTML) + // + // See https://www.iana.org/assignments/media-types/media-types.xhtml. + string mime_type = 1; + } + + // Data representation. One of + // [struct_data][google.cloud.discoveryengine.v1.Document.struct_data] or + // [json_data][google.cloud.discoveryengine.v1.Document.json_data] should be + // provided otherwise an `INVALID_ARGUMENT` error is thrown. + oneof data { + // The structured JSON data for the document. It should conform to the + // registered [Schema.schema][google.cloud.discoveryengine.v1.Schema.schema] + // or an `INVALID_ARGUMENT` error is thrown. + google.protobuf.Struct struct_data = 4; + + // The JSON string representation of the document. It should conform to the + // registered [Schema.schema][google.cloud.discoveryengine.v1.Schema.schema] + // or an `INVALID_ARGUMENT` error is thrown. + string json_data = 5; + } + + // Immutable. The full resource name of the document. + // Format: + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document_id}`. + // + // This field must be a UTF-8 encoded string with a length limit of 1024 + // characters. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The identifier of the document. + // + // Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + // standard with a length limit of 63 characters. + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // The identifier of the schema located in the same data store. + string schema_id = 3; + + // The unstructured data linked to this document. Content must be set if this + // document is under a + // `CONTENT_REQUIRED` data store. + Content content = 10; + + // The identifier of the parent document. Currently supports at most two level + // document hierarchy. + // + // Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + // standard with a length limit of 63 characters. + string parent_document_id = 7; + + // Output only. This field is OUTPUT_ONLY. + // It contains derived data that are not in the original input document. + google.protobuf.Struct derived_struct_data = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document_service.proto new file mode 100644 index 00000000000..b46cd918f4c --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document_service.proto @@ -0,0 +1,313 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1/document.proto"; +import "google/cloud/discoveryengine/v1/import_config.proto"; +import "google/cloud/discoveryengine/v1/purge_config.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "DocumentServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; + +// Service for ingesting [Document][google.cloud.discoveryengine.v1.Document] +// information of the customer's website. +service DocumentService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Gets a [Document][google.cloud.discoveryengine.v1.Document]. + rpc GetDocument(GetDocumentRequest) returns (Document) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" + additional_bindings { + get: "/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s. + rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents" + additional_bindings { + get: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a [Document][google.cloud.discoveryengine.v1.Document]. + rpc CreateDocument(CreateDocumentRequest) returns (Document) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents" + body: "document" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents" + body: "document" + } + }; + option (google.api.method_signature) = "parent,document,document_id"; + } + + // Updates a [Document][google.cloud.discoveryengine.v1.Document]. + rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { + option (google.api.http) = { + patch: "/v1/{document.name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" + body: "document" + additional_bindings { + patch: "/v1/{document.name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" + body: "document" + } + }; + } + + // Deletes a [Document][google.cloud.discoveryengine.v1.Document]. + rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" + additional_bindings { + delete: "/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Bulk import of multiple + // [Document][google.cloud.discoveryengine.v1.Document]s. Request processing + // may be synchronous. Non-existing items will be created. + // + // Note: It is possible for a subset of the + // [Document][google.cloud.discoveryengine.v1.Document]s to be successfully + // updated. + rpc ImportDocuments(ImportDocumentsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:import" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:import" + body: "*" + } + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.discoveryengine.v1.ImportDocumentsResponse" + metadata_type: "google.cloud.discoveryengine.v1.ImportDocumentsMetadata" + }; + } + + // Permanently deletes all selected + // [Document][google.cloud.discoveryengine.v1.Document]s in a branch. + // + // This process is asynchronous. Depending on the number of + // [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this + // operation can take hours to complete. Before the delete operation + // completes, some [Document][google.cloud.discoveryengine.v1.Document]s might + // still be returned by + // [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] + // or + // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments]. + // + // To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s + // to be deleted, set + // [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force] + // to false. + rpc PurgeDocuments(PurgeDocumentsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:purge" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:purge" + body: "*" + } + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.discoveryengine.v1.PurgeDocumentsResponse" + metadata_type: "google.cloud.discoveryengine.v1.PurgeDocumentsMetadata" + }; + } +} + +// Request message for +// [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] +// method. +message GetDocumentRequest { + // Required. Full resource name of + // [Document][google.cloud.discoveryengine.v1.Document], such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + // + // If the caller does not have permission to access the + // [Document][google.cloud.discoveryengine.v1.Document], regardless of whether + // or not it exists, a `PERMISSION_DENIED` error is returned. + // + // If the requested [Document][google.cloud.discoveryengine.v1.Document] does + // not exist, a `NOT_FOUND` error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Document" + } + ]; +} + +// Request message for +// [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments] +// method. +message ListDocumentsRequest { + // Required. The parent branch resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + // Use `default_branch` as the branch ID, to list documents under the default + // branch. + // + // If the caller does not have permission to list [Documents][]s under this + // branch, regardless of whether or not this branch exists, a + // `PERMISSION_DENIED` error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Branch" + } + ]; + + // Maximum number of [Document][google.cloud.discoveryengine.v1.Document]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. + int32 page_size = 2; + + // A page token + // [ListDocumentsResponse.next_page_token][google.cloud.discoveryengine.v1.ListDocumentsResponse.next_page_token], + // received from a previous + // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments] + // must match the call that provided the page token. Otherwise, an + // `INVALID_ARGUMENT` error is returned. + string page_token = 3; +} + +// Response message for +// [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments] +// method. +message ListDocumentsResponse { + // The [Document][google.cloud.discoveryengine.v1.Document]s. + repeated Document documents = 1; + + // A token that can be sent as + // [ListDocumentsRequest.page_token][google.cloud.discoveryengine.v1.ListDocumentsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request message for +// [DocumentService.CreateDocument][google.cloud.discoveryengine.v1.DocumentService.CreateDocument] +// method. +message CreateDocumentRequest { + // Required. The parent resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Branch" + } + ]; + + // Required. The [Document][google.cloud.discoveryengine.v1.Document] to + // create. + Document document = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the + // [Document][google.cloud.discoveryengine.v1.Document], which will become the + // final component of the + // [Document.name][google.cloud.discoveryengine.v1.Document.name]. + // + // If the caller does not have permission to create the + // [Document][google.cloud.discoveryengine.v1.Document], regardless of whether + // or not it exists, a `PERMISSION_DENIED` error is returned. + // + // This field must be unique among all + // [Document][google.cloud.discoveryengine.v1.Document]s with the same + // [parent][google.cloud.discoveryengine.v1.CreateDocumentRequest.parent]. + // Otherwise, an `ALREADY_EXISTS` error is returned. + // + // This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + // standard with a length limit of 63 characters. Otherwise, an + // `INVALID_ARGUMENT` error is returned. + string document_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for +// [DocumentService.UpdateDocument][google.cloud.discoveryengine.v1.DocumentService.UpdateDocument] +// method. +message UpdateDocumentRequest { + // Required. The document to update/create. + // + // If the caller does not have permission to update the + // [Document][google.cloud.discoveryengine.v1.Document], regardless of whether + // or not it exists, a `PERMISSION_DENIED` error is returned. + // + // If the [Document][google.cloud.discoveryengine.v1.Document] to update does + // not exist and + // [allow_missing][google.cloud.discoveryengine.v1.UpdateDocumentRequest.allow_missing] + // is not set, a `NOT_FOUND` error is returned. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // If set to true, and the + // [Document][google.cloud.discoveryengine.v1.Document] is not found, a new + // [Document][google.cloud.discoveryengine.v1.Document] will be created. + bool allow_missing = 2; +} + +// Request message for +// [DocumentService.DeleteDocument][google.cloud.discoveryengine.v1.DocumentService.DeleteDocument] +// method. +message DeleteDocumentRequest { + // Required. Full resource name of + // [Document][google.cloud.discoveryengine.v1.Document], such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + // + // If the caller does not have permission to delete the + // [Document][google.cloud.discoveryengine.v1.Document], regardless of whether + // or not it exists, a `PERMISSION_DENIED` error is returned. + // + // If the [Document][google.cloud.discoveryengine.v1.Document] to delete does + // not exist, a `NOT_FOUND` error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Document" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/import_config.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/import_config.proto new file mode 100644 index 00000000000..4680ebafde2 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/import_config.proto @@ -0,0 +1,334 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1/document.proto"; +import "google/cloud/discoveryengine/v1/user_event.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; + +// Cloud Storage location for input content. +message GcsSource { + // Required. Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. + // + // A request can contain at most 100 files (or 100,000 files if `data_schema` + // is `content`). Each file can be up to 2 GB (or 100 MB if `data_schema` is + // `content`). + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for document imports: + // + // * `document` (default): One JSON + // [Document][google.cloud.discoveryengine.v1.Document] per line. Each + // document must + // have a valid [Document.id][google.cloud.discoveryengine.v1.Document.id]. + // * `content`: Unstructured data (e.g. PDF, HTML). Each file matched by + // `input_uris` will become a document, with the ID set to the first 128 + // bits of SHA256(URI) encoded as a hex string. + // * `custom`: One custom data JSON per row in arbitrary format that conforms + // the defined [Schema][google.cloud.discoveryengine.v1.Schema] of the data + // store. This can only be used by the GENERIC Data Store vertical. + // + // Supported values for user even imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.discoveryengine.v1.UserEvent] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + google.type.Date partition_date = 5; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 1; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 3 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 4; + + // The schema to use when parsing the data from the source. + // + // Supported values for user event imports: + // + // * `user_event` (default): One + // [UserEvent][google.cloud.discoveryengine.v1.UserEvent] per row. + // + // Supported values for document imports: + // + // * `document` (default): One + // [Document][google.cloud.discoveryengine.v1.Document] format per + // row. Each document must have a valid + // [Document.id][google.cloud.discoveryengine.v1.Document.id] and one of + // [Document.json_data][google.cloud.discoveryengine.v1.Document.json_data] + // or + // [Document.struct_data][google.cloud.discoveryengine.v1.Document.struct_data]. + // * `custom`: One custom data per row in arbitrary format that conforms the + // defined [Schema][google.cloud.discoveryengine.v1.Schema] of the data + // store. This can only be used by the GENERIC Data Store vertical. + string data_schema = 6; +} + +// Configuration of destination for Import related errors. +message ImportErrorConfig { + // Required. Errors destination. + oneof destination { + // Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors will be written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // The inline source for the input config for ImportUserEvents method. + message InlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // The desired input source of the user event data. + oneof source { + // Required. The Inline source for the input content for UserEvents. + InlineSource inline_source = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Cloud Storage location for the input content. + GcsSource gcs_source = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. BigQuery input source. + BigQuerySource bigquery_source = 4 [(google.api.field_behavior) = REQUIRED]; + } + + // Required. Parent DataStore resource name, of the form + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorConfig error_config = 5; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorConfig error_config = 2; + + // Count of user events imported with complete existing Documents. + int64 joined_events_count = 3; + + // Count of user events imported, but with Document information not found + // in the existing Branch. + int64 unjoined_events_count = 4; +} + +// Metadata related to the progress of the Import operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ImportUserEventsMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; +} + +// Metadata related to the progress of the ImportDocuments operation. This will +// be returned by the google.longrunning.Operation.metadata field. +message ImportDocumentsMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; +} + +// Request message for Import methods. +message ImportDocumentsRequest { + // The inline source for the input config for ImportDocuments method. + message InlineSource { + // Required. A list of documents to update/create. Each document must have a + // valid [Document.id][google.cloud.discoveryengine.v1.Document.id]. + // Recommended max of 100 items. + repeated Document documents = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // Indicates how imported documents are reconciled with the existing documents + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new documents or updates existing documents. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire document dataset. Existing + // documents may be deleted if they are not present in the source location. + FULL = 2; + } + + // Required. The source of the input. + oneof source { + // The Inline source for the input content for documents. + InlineSource inline_source = 2; + + // Cloud Storage location for the input content. + GcsSource gcs_source = 3; + + // BigQuery input source. + BigQuerySource bigquery_source = 4; + } + + // Required. The parent branch resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + // Requires create/update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Branch" + } + ]; + + // The desired location of errors incurred during the Import. + ImportErrorConfig error_config = 5; + + // The mode of reconciliation between existing documents and the documents to + // be imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 6; + + // Whether to automatically generate IDs for the documents if absent. + // + // If set to `true`, + // [Document.id][google.cloud.discoveryengine.v1.Document.id]s are + // automatically generated based on the hash of the payload, where IDs may not + // be consistent during multiple imports. In which case + // [ReconciliationMode.FULL][google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.FULL] + // is highly recommended to avoid duplicate contents. If unset or set to + // `false`, [Document.id][google.cloud.discoveryengine.v1.Document.id]s have + // to be specified using + // [id_field][google.cloud.discoveryengine.v1.ImportDocumentsRequest.id_field], + // otherwises, documents without IDs will fail to be imported. + // + // Only set this field when using + // [GcsSource][google.cloud.discoveryengine.v1.GcsSource] or + // [BigQuerySource][google.cloud.discoveryengine.v1.BigQuerySource], and when + // [GcsSource.data_schema][google.cloud.discoveryengine.v1.GcsSource.data_schema] + // or + // [BigQuerySource.data_schema][google.cloud.discoveryengine.v1.BigQuerySource.data_schema] + // is `custom`. Otherwise, an INVALID_ARGUMENT error is thrown. + bool auto_generate_ids = 8; + + // The field in the Cloud Storage and BigQuery sources that indicates the + // unique IDs of the documents. + // + // For [GcsSource][google.cloud.discoveryengine.v1.GcsSource] it is the key of + // the JSON field. For instance, `my_id` for JSON `{"my_id": "some_uuid"}`. + // For [BigQuerySource][google.cloud.discoveryengine.v1.BigQuerySource] it is + // the column name of the BigQuery table where the unique ids are stored. + // + // The values of the JSON field or the BigQuery column will be used as the + // [Document.id][google.cloud.discoveryengine.v1.Document.id]s. The JSON field + // or the BigQuery column must be of string type, and the values must be set + // as valid strings conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + // with 1-63 characters. Otherwise, documents without valid IDs will fail to + // be imported. + // + // Only set this field when using + // [GcsSource][google.cloud.discoveryengine.v1.GcsSource] or + // [BigQuerySource][google.cloud.discoveryengine.v1.BigQuerySource], and when + // [GcsSource.data_schema][google.cloud.discoveryengine.v1.GcsSource.data_schema] + // or + // [BigQuerySource.data_schema][google.cloud.discoveryengine.v1.BigQuerySource.data_schema] + // is `custom`. And only set this field when + // [auto_generate_ids][google.cloud.discoveryengine.v1.ImportDocumentsRequest.auto_generate_ids] + // is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. + // + // If it is unset, a default value `_id` is used when importing from the + // allowed data sources. + string id_field = 9; +} + +// Response of the +// [ImportDocumentsRequest][google.cloud.discoveryengine.v1.ImportDocumentsRequest]. +// If the long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportDocumentsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorConfig error_config = 2; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/purge_config.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/purge_config.proto new file mode 100644 index 00000000000..8c0173b12c8 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/purge_config.proto @@ -0,0 +1,86 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; + +// Request message for +// [DocumentService.PurgeDocuments][google.cloud.discoveryengine.v1.DocumentService.PurgeDocuments] +// method. +message PurgeDocumentsRequest { + // Required. The parent resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Branch" + } + ]; + + // Required. Filter matching documents to purge. Only currently supported + // value is + // `*` (all items). + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually performs the purge. If `force` is set to false, return the + // expected purge count without deleting any documents. + bool force = 3; +} + +// Response message for +// [DocumentService.PurgeDocuments][google.cloud.discoveryengine.v1.DocumentService.PurgeDocuments] +// method. If the long running operation is successfully done, then this message +// is returned by the google.longrunning.Operations.response field. +message PurgeDocumentsResponse { + // The total count of documents purged as a result of the operation. + int64 purge_count = 1; + + // A sample of document names that will be deleted. Only populated if `force` + // is set to false. A max of 100 names will be returned and the names are + // chosen at random. + repeated string purge_sample = 2 [(google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Document" + }]; +} + +// Metadata related to the progress of the PurgeDocuments operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeDocumentsMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were deleted successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema.proto new file mode 100644 index 00000000000..1d8709acb12 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema.proto @@ -0,0 +1,58 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "SchemaProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; + +// Defines the structure and layout of a type of document data. +message Schema { + option (google.api.resource) = { + type: "discoveryengine.googleapis.com/Schema" + pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}" + pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}" + }; + + // Schema representation. One of + // [struct_schema][google.cloud.discoveryengine.v1.Schema.struct_schema] or + // [json_schema][google.cloud.discoveryengine.v1.Schema.json_schema] should be + // provided otherwise an INVALID_ARGUMENT error is thrown. + oneof schema { + // The structured representation of the schema. + google.protobuf.Struct struct_schema = 2; + + // The JSON representation of the schema. + string json_schema = 3; + } + + // Immutable. The full resource name of the schema, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + // + // This field must be a UTF-8 encoded string with a length limit of 1024 + // characters. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema_service.proto new file mode 100644 index 00000000000..74ac7f70f5c --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema_service.proto @@ -0,0 +1,256 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1/schema.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "SchemaServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; + +// Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s. +service SchemaService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Gets a [Schema][google.cloud.discoveryengine.v1.Schema]. + rpc GetSchema(GetSchemaRequest) returns (Schema) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/dataStores/*/schemas/*}" + additional_bindings { + get: "/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s. + rpc ListSchemas(ListSchemasRequest) returns (ListSchemasResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/dataStores/*}/schemas" + additional_bindings { + get: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/schemas" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a [Schema][google.cloud.discoveryengine.v1.Schema]. + rpc CreateSchema(CreateSchemaRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/dataStores/*}/schemas" + body: "schema" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/schemas" + body: "schema" + } + }; + option (google.api.method_signature) = "parent,schema,schema_id"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.discoveryengine.v1.Schema" + metadata_type: "google.cloud.discoveryengine.v1.CreateSchemaMetadata" + }; + } + + // Updates a [Schema][google.cloud.discoveryengine.v1.Schema]. + rpc UpdateSchema(UpdateSchemaRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{schema.name=projects/*/locations/*/dataStores/*/schemas/*}" + body: "schema" + additional_bindings { + patch: "/v1/{schema.name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" + body: "schema" + } + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.discoveryengine.v1.Schema" + metadata_type: "google.cloud.discoveryengine.v1.UpdateSchemaMetadata" + }; + } + + // Deletes a [Schema][google.cloud.discoveryengine.v1.Schema]. + rpc DeleteSchema(DeleteSchemaRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/dataStores/*/schemas/*}" + additional_bindings { + delete: "/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.discoveryengine.v1.DeleteSchemaMetadata" + }; + } +} + +// Request message for +// [SchemaService.GetSchema][google.cloud.discoveryengine.v1.SchemaService.GetSchema] +// method. +message GetSchemaRequest { + // Required. The full resource name of the schema, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Schema" + } + ]; +} + +// Request message for +// [SchemaService.ListSchemas][google.cloud.discoveryengine.v1.SchemaService.ListSchemas] +// method. +message ListSchemasRequest { + // Required. The parent data store resource name, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // The maximum number of [Schema][google.cloud.discoveryengine.v1.Schema]s to + // return. The service may return fewer than this value. + // + // If unspecified, at most 100 + // [Schema][google.cloud.discoveryengine.v1.Schema]s will be returned. + // + // The maximum value is 1000; values above 1000 will be coerced to 1000. + int32 page_size = 2; + + // A page token, received from a previous + // [SchemaService.ListSchemas][google.cloud.discoveryengine.v1.SchemaService.ListSchemas] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SchemaService.ListSchemas][google.cloud.discoveryengine.v1.SchemaService.ListSchemas] + // must match the call that provided the page token. + string page_token = 3; +} + +// Response message for +// [SchemaService.ListSchemas][google.cloud.discoveryengine.v1.SchemaService.ListSchemas] +// method. +message ListSchemasResponse { + // The [Schema][google.cloud.discoveryengine.v1.Schema]s. + repeated Schema schemas = 1; + + // A token that can be sent as + // [ListSchemasRequest.page_token][google.cloud.discoveryengine.v1.ListSchemasRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request message for +// [SchemaService.CreateSchema][google.cloud.discoveryengine.v1.SchemaService.CreateSchema] +// method. +message CreateSchemaRequest { + // Required. The parent data store resource name, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // Required. The [Schema][google.cloud.discoveryengine.v1.Schema] to create. + Schema schema = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the + // [Schema][google.cloud.discoveryengine.v1.Schema], which will become the + // final component of the + // [Schema.name][google.cloud.discoveryengine.v1.Schema.name]. + // + // This field should conform to + // [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length + // limit of 63 characters. + string schema_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for +// [SchemaService.UpdateSchema][google.cloud.discoveryengine.v1.SchemaService.UpdateSchema] +// method. +message UpdateSchemaRequest { + // Required. The [Schema][google.cloud.discoveryengine.v1.Schema] to update. + Schema schema = 1 [(google.api.field_behavior) = REQUIRED]; + + // If set to true, and the [Schema][google.cloud.discoveryengine.v1.Schema] is + // not found, a new [Schema][google.cloud.discoveryengine.v1.Schema] will be + // created. In this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for +// [SchemaService.DeleteSchema][google.cloud.discoveryengine.v1.SchemaService.DeleteSchema] +// method. +message DeleteSchemaRequest { + // Required. The full resource name of the schema, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Schema" + } + ]; +} + +// Metadata for Create Schema LRO. +message CreateSchemaMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} + +// Metadata for UpdateSchema LRO. +message UpdateSchemaMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} + +// Metadata for DeleteSchema LRO. +message DeleteSchemaMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/search_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/search_service.proto new file mode 100644 index 00000000000..6062d593cae --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/search_service.proto @@ -0,0 +1,289 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1/common.proto"; +import "google/cloud/discoveryengine/v1/document.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; + +// Service for search. +service SearchService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v1/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:search" + body: "*" + additional_bindings { + post: "/v1/{serving_config=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:search" + body: "*" + } + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] +// method. +message SearchRequest { + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. In this case, server behavior + // defaults to + // [Condition.DISABLED][google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.discoveryengine.v1.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by the Search API. + AUTO = 2; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + } + + // The specification for query spell correction. + message SpellCorrectionSpec { + // Enum describing under which mode spell correction should occur. + enum Mode { + // Unspecified spell correction mode. In this case, server behavior + // defaults to + // [Mode.AUTO][google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Search API will try to find a spell suggestion if there + // is any and put in the + // [SearchResponse.corrected_query][google.cloud.discoveryengine.v1.SearchResponse.corrected_query]. + // The spell suggestion will not be used as the search query. + SUGGESTION_ONLY = 1; + + // Automatic spell correction built by the Search API. Search will + // be based on the corrected query if found. + AUTO = 2; + } + + // The mode under which spell correction should take effect to + // replace the original search query. Default to + // [Mode.AUTO][google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The specification that configs the desired behavior of the UCS content + // search. + message ContentSearchSpec { + // The specification that configs the snippet in the search results. + message SnippetSpec { + // Max number of snippets returned in each search result. + // If the matching snippets is less than the max_snippet_count, return all + // of the snippets; otherwise, return the max_snippet_count. + // + // At most 5 snippets will be returned for each SearchResult. + int32 max_snippet_count = 1; + + // if true, only snippet reference is returned. + bool reference_only = 2; + } + + // If there is no snippet spec provided, there will be no snippet in the + // search result. + SnippetSpec snippet_spec = 1; + } + + // Required. The resource name of the Search serving config, such as + // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + // This field is used to identify the serving configuration name, set + // of models used to make the search. + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/ServingConfig" + } + ]; + + // The branch resource name, such as + // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + // + // Use `default_branch` as the branch ID or leave this field empty, to search + // documents under the default branch. + string branch = 2 [(google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Branch" + }]; + + // Raw search query. + string query = 3; + + // Maximum number of [Document][google.cloud.discoveryengine.v1.Document]s to + // return. If unspecified, defaults to a reasonable value. The maximum allowed + // value is 100. Values above 100 will be coerced to 100. + // + // If this field is negative, an `INVALID_ARGUMENT` is returned. + int32 page_size = 4; + + // A page token received from a previous + // [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] + // must match the call that provided the page token. Otherwise, an + // `INVALID_ARGUMENT` error is returned. + string page_token = 5; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the + // [Document][google.cloud.discoveryengine.v1.Document]s deemed by the API as + // relevant) in search results. This field is only considered if + // [page_token][google.cloud.discoveryengine.v1.SearchRequest.page_token] is + // unset. + // + // If this field is negative, an `INVALID_ARGUMENT` is returned. + int32 offset = 6; + + // Information about the end user. + // Highly recommended for analytics. The user_agent string in UserInfo will + // be used to deduce device_type for analytics. + UserInfo user_info = 21; + + // Additional search parameters. + // + // For public website search only, supported values are: + // + // * `user_country_code`: string. Default empty. If set to non-empty, results + // are restricted or boosted based on the location provided. + // * `search_type`: double. Default empty. Enables non-webpage searching + // depending on the value. The only valid non-default value is 1, + // which enables image searching. + map params = 11; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. + QueryExpansionSpec query_expansion_spec = 13; + + // The spell correction specification that specifies the mode under + // which spell correction will take effect. + SpellCorrectionSpec spell_correction_spec = 14; + + // 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. + // + // This field should NOT have a fixed value such as `unknown_visitor`. + // + // This should be the same identifier as + // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id] + // and + // [CompleteQueryRequest.user_pseudo_id][google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id] + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + string user_pseudo_id = 15; + + // The content search spec that configs the desired behavior of content + // search. + ContentSearchSpec content_search_spec = 24; + + // Whether to turn on safe search. This is only supported for + // [ContentConfig.PUBLIC_WEBSITE][]. + bool safe_search = 20; + + // The user 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. + map user_labels = 22; +} + +// Response message for +// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] +// method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Document.id][google.cloud.discoveryengine.v1.Document.id] of the + // searched [Document][google.cloud.discoveryengine.v1.Document]. + string id = 1; + + // The document data snippet in the search response. Only fields that are + // marked as retrievable are populated. + Document document = 2; + } + + // A list of matched documents. The order represents the ranking. + repeated SearchResult results = 1; + + // The estimated total count of matched items irrespective of pagination. The + // count of [results][google.cloud.discoveryengine.v1.SearchResponse.results] + // returned by pagination may be less than the + // [total_size][google.cloud.discoveryengine.v1.SearchResponse.total_size] + // that matches. + int32 total_size = 3; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.discoveryengine.v1.UserEvent] logs resulting from + // this search, which enables accurate attribution of search model + // performance. + string attribution_token = 4; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.discoveryengine.v1.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 5; + + // Contains the spell corrected query, if found. If the spell correction type + // is AUTOMATIC, then the search results are based on corrected_query. + // Otherwise the original query is used for search. + string corrected_query = 7; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event.proto new file mode 100644 index 00000000000..f141a2911e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event.proto @@ -0,0 +1,458 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1/common.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; + +// UserEvent captures all metadata information Discovery Engine API needs to +// know about how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // Generic values: + // + // * `search`: Search for Documents. + // * `view-item`: Detailed page view of a Document. + // * `view-item-list`: View of a panel or ordered list of Documents. + // * `view-home-page`: View of the home page. + // * `view-category-page`: View of a category page, e.g. Home > Men > Jeans + // + // Retail-related values: + // + // * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping + // * `purchase`: Purchase an item(s) + // + // Media-related values: + // + // * `media-play`: Start/resume watching a video, playing a song, etc. + // * `media-complete`: Finished or stopped midway through a video, song, etc. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. 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 log in/out of the website. + // + // Do not set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded model + // quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analytics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string user_pseudo_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.discoveryengine.v1.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // Information about the end user. + UserInfo user_info = 4; + + // Should set to true if the request is made directly from the end user, in + // which case the + // [UserEvent.user_info.user_agent][google.cloud.discoveryengine.v1.UserInfo.user_agent] + // can be populated from the HTTP request. + // + // This flag should be set only if the API request is made directly from the + // end user such as a mobile app (and not if a gateway or a server is + // processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1.UserEventService.CollectUserEvent]. + bool direct_user_request = 5; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the session_id: + // + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id] + // as prefix. + string session_id = 6; + + // Page metadata such as categories and other critical information for certain + // event types such as `view-category-page`. + PageInfo page_info = 7; + + // Token to attribute an API response to user action(s) to trigger the event. + // + // Highly recommended for user events that are the result of + // [RecommendationService.Recommend][]. This field enables accurate + // attribution of recommendation model performance. + // + // The value must be one of: + // + // * [PredictResponse.attribution_token][] for events that are the result of + // [RecommendationService.Recommend][]. + // * [SearchResponse.attribution_token][google.cloud.discoveryengine.v1.SearchResponse.attribution_token] for events that are the result of + // [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]. + // * [CompleteQueryResponse.attribution_token][] for events that are the + // result of + // [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1.CompletionService.CompleteQuery]. + // + // This token enables us to accurately attribute page view or conversion + // completion back to the event and the particular predict response containing + // this clicked/purchased product. If user clicks on product K in the + // recommendation results, pass [PredictResponse.attribution_token][] as a URL + // parameter to product K's page. When recording events on product K's page, + // log the [PredictResponse.attribution_token][] to this field. + string attribution_token = 8; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the documents being filtered. + // + // One example is for `search` events, the associated + // [SearchRequest][google.cloud.discoveryengine.v1.SearchRequest] may contain + // a filter expression in [SearchRequest.filter][] conforming to + // https://google.aip.dev/160#filtering. + // + // Similarly, for `view-item-list` events that are generated from a + // [RecommendationService.RecommendRequest][], this field may be populated + // directly from [RecommendationService.RecommendRequest.filter][] conforming + // to https://google.aip.dev/160#filtering. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 9; + + // List of Documents associated with this user event. + // + // This field is optional except for the following event types: + // + // * `view-item` + // * `add-to-cart` + // * `purchase` + // * `media-play` + // * `media-complete` + // + // In a `search` event, this field represents the documents returned to the + // end user on the current page (the end user may have not finished browsing + // the whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [UserEvent.documents][google.cloud.discoveryengine.v1.UserEvent.documents] + // is desired. + repeated DocumentInfo documents = 10; + + // Panel metadata associated with this user event. + PanelInfo panel = 11; + + // Search API details related to the event. + // + // This field should be set for `search` event. + SearchInfo search_info = 12; + + // CompleteQuery API details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionInfo completion_info = 13; + + // The transaction metadata (if any) associated with this user event. + TransactionInfo transaction_info = 14; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups on the customer end. + repeated string tag_ids = 15; + + // The promotion IDs if this is an event associated with promotions. + // Currently, this field is restricted to at most one ID. + repeated string promotion_ids = 16; + + // Extra user event features to include in the recommendation model. + // These attributes must NOT contain data that needs to be parsed or processed + // further, e.g. JSON or other encodings. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Discovery Engine API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an + // `INVALID_ARGUMENT` error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // ` traffic_channel`, which is how a user arrives at the site. Users can + // arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 17; + + // Media-specific info. + MediaInfo media_info = 18; +} + +// Detailed page information. +message PageInfo { + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string pageview_id = 1; + + // The most specific category associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategory" : "Sales > 2017 Black Friday Deals". + // + // Required for `view-category-page` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string page_category = 2; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 3; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. However, some browser + // privacy restrictions may cause this field to be empty. + string referrer_uri = 4; +} + +// Detailed search information. +message SearchInfo { + // The user's search query. + // + // See + // [SearchRequest.query][google.cloud.discoveryengine.v1.SearchRequest.query] + // for definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.discoveryengine.v1.SearchInfo.search_query] or + // [PageInfo.page_category][google.cloud.discoveryengine.v1.PageInfo.page_category] + // is required for `search` events. Other event types should not set this + // field. Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 1; + + // The order in which products are returned, if applicable. + // + // See [SearchRequest.order_by][] for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 2; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See + // [SearchRequest.offset][google.cloud.discoveryengine.v1.SearchRequest.offset] + // for definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + optional int32 offset = 3; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionInfo { + // End user selected [CompleteQueryResponse.CompletionResult.suggestion][]. + string selected_suggestion = 1; + + // End user selected [CompleteQueryResponse.CompletionResult.suggestion][] + // position, starting from 0. + int32 selected_position = 2; +} + +// A transaction represents the entire purchase transaction. +message TransactionInfo { + // Required. Total non-zero value associated with the transaction. This value + // may include shipping, tax, or other adjustments to the total value that you + // want to include. + optional float value = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency = 2 [(google.api.field_behavior) = REQUIRED]; + + // The transaction ID with a length limit of 128 characters. + string transaction_id = 3; + + // All the taxes associated with the transaction. + optional float tax = 4; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = [value][google.cloud.discoveryengine.v1.TransactionInfo.value] - + // [tax][google.cloud.discoveryengine.v1.TransactionInfo.tax] - + // [cost][google.cloud.discoveryengine.v1.TransactionInfo.cost] + optional float cost = 5; + + // The total discount(s) value applied to this transaction. + // This figure should be excluded from + // [TransactionInfo.value][google.cloud.discoveryengine.v1.TransactionInfo.value] + // + // For example, if a user paid + // [TransactionInfo.value][google.cloud.discoveryengine.v1.TransactionInfo.value] + // amount, then nominal (pre-discount) value of the transaction is the sum of + // [TransactionInfo.value][google.cloud.discoveryengine.v1.TransactionInfo.value] + // and + // [TransactionInfo.discount_value][google.cloud.discoveryengine.v1.TransactionInfo.discount_value] + // + // This means that profit is calculated the same way, regardless of the + // discount value, and that + // [TransactionInfo.discount_value][google.cloud.discoveryengine.v1.TransactionInfo.discount_value] + // can be larger than + // [TransactionInfo.value][google.cloud.discoveryengine.v1.TransactionInfo.value]: + // + // * Profit = [value][google.cloud.discoveryengine.v1.TransactionInfo.value] - + // [tax][google.cloud.discoveryengine.v1.TransactionInfo.tax] - + // [cost][google.cloud.discoveryengine.v1.TransactionInfo.cost] + optional float discount_value = 6; +} + +// Detailed document information associated with a user event. +message DocumentInfo { + // A required descriptor of the associated + // [Document][google.cloud.discoveryengine.v1.Document]. + // + // * If [id][google.cloud.discoveryengine.v1.DocumentInfo.id] is specified, + // then the default values for + // `{location}`, `{collection_id}`, `{data_store_id}`, and `{branch_id}` are + // used when annotating with the stored Document. + // + // * If [name][google.cloud.discoveryengine.v1.DocumentInfo.name] is + // specified, then the provided values (default values allowed) for + // `{location}`, `{collection_id}`, `{data_store_id}`, and + // `{branch_id}` are used when annotating with the stored Document. + oneof document_descriptor { + // Required. The Document resource ID. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The Document resource full name, of the form: + // `projects/{project_id}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}` + string name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Document" + } + ]; + } + + // Quantity of the Document associated with the user event. Defaults to 1. + // + // For example, this field will be 2 if two quantities of the same Document + // are involved in a `add-to-cart` event. + // + // Required for events of the following event types: + // + // * `add-to-cart` + // * `purchase` + optional int32 quantity = 3; + + // The promotion IDs associated with this Document. + // Currently, this field is restricted to at most one ID. + repeated string promotion_ids = 4; +} + +// Detailed panel information associated with a user event. +message PanelInfo { + // Required. The panel ID. + string panel_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // The display name of the panel. + string display_name = 3; + + // The ordered position of the panel, if shown to the user with other panels. + // If set, then + // [total_panels][google.cloud.discoveryengine.v1.PanelInfo.total_panels] must + // also be set. + optional int32 panel_position = 4; + + // The total number of panels, including this one, shown to the user. + // Must be set if + // [panel_position][google.cloud.discoveryengine.v1.PanelInfo.panel_position] + // is set. + optional int32 total_panels = 5; +} + +// Media-specific user event information. +message MediaInfo { + // The media progress time in seconds, if applicable. + // For example, if the end user has finished 90 seconds of a playback video, + // then [MediaInfo.media_progress_duration.seconds][Duration.seconds] should + // be set to 90. + google.protobuf.Duration media_progress_duration = 1; + + // Media progress should be computed using only the media_progress_duration + // relative to the media total length. + // + // This value must be between `[0, 1.0]` inclusive. + // + // If this is not a playback or the progress cannot be computed (e.g. ongoing + // livestream), this field should be unset. + optional float media_progress_percentage = 2; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event_service.proto new file mode 100644 index 00000000000..4dbeea46c58 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event_service.proto @@ -0,0 +1,133 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1/import_config.proto"; +import "google/cloud/discoveryengine/v1/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; + +// Service for ingesting end user actions on a website to Discovery Engine API. +service UserEventService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/dataStores/*}/userEvents:write" + body: "user_event" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:write" + body: "user_event" + } + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Discovery Engine API JavaScript pixel and + // Google Tag Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/dataStores/*}/userEvents:collect" + additional_bindings { + get: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:collect" + } + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // Operation.response is of type ImportResponse. Note that it is + // possible for a subset of the items to be successfully inserted. + // Operation.metadata is of type ImportMetadata. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/dataStores/*}/userEvents:import" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:import" + body: "*" + } + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.discoveryengine.v1.ImportUserEventsResponse" + metadata_type: "google.cloud.discoveryengine.v1.ImportUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent DataStore resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // Required. User event to write. + optional UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent DataStore resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // 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. + optional string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + optional int64 ets = 4; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/completion_service.complete_query.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/completion_service.complete_query.js new file mode 100644 index 00000000000..3b28773bbfe --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/completion_service.complete_query.js @@ -0,0 +1,99 @@ +// Copyright 2023 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(dataStore, query) { + // [START discoveryengine_v1_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. The parent data store resource name for which the completion is + * performed, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store`. + */ + // const dataStore = 'abc123' + /** + * Required. The typeahead input used to fetch suggestions. Maximum length is + * 128 characters. + */ + // const query = 'abc123' + /** + * Selects data model of query suggestions for serving. Currently supported + * values: + * * `document` - Using suggestions generated from user-imported documents. + * * `search-history` - Using suggestions generated from the past history of + * SearchService.Search google.cloud.discoveryengine.v1.SearchService.Search + * API calls. Do not use it when there is no traffic for Search API. + * * `user-event` - Using suggestions generated from user-imported search + * events. + * Default values: + * * `document` is the default model for regular dataStores. + * * `search-history` is the default model for + * IndustryVertical.SITE_SEARCH google.cloud.discoveryengine.v1.IndustryVertical.SITE_SEARCH + * dataStores. + */ + // const queryModel = 'abc123' + /** + * 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. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * UserEvent.user_pseudo_id google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id + * and + * SearchRequest.user_pseudo_id google.cloud.discoveryengine.v1.SearchRequest.user_pseudo_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + */ + // const userPseudoId = 'abc123' + + // Imports the Discoveryengine library + const {CompletionServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + dataStore, + query, + }; + + // Run request + const response = await discoveryengineClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END discoveryengine_v1_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.create_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.create_document.js new file mode 100644 index 00000000000..ecc3fd1a633 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.create_document.js @@ -0,0 +1,86 @@ +// Copyright 2023 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, document, documentId) { + // [START discoveryengine_v1_generated_DocumentService_CreateDocument_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 resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + */ + // const parent = 'abc123' + /** + * Required. The Document google.cloud.discoveryengine.v1.Document to + * create. + */ + // const document = {} + /** + * Required. The ID to use for the + * Document google.cloud.discoveryengine.v1.Document, which will become the + * final component of the + * Document.name google.cloud.discoveryengine.v1.Document.name. + * If the caller does not have permission to create the + * Document google.cloud.discoveryengine.v1.Document, regardless of whether + * or not it exists, a `PERMISSION_DENIED` error is returned. + * This field must be unique among all + * Document google.cloud.discoveryengine.v1.Document s with the same + * parent google.cloud.discoveryengine.v1.CreateDocumentRequest.parent. + * Otherwise, an `ALREADY_EXISTS` error is returned. + * This field must conform to RFC-1034 (https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + */ + // const documentId = 'abc123' + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callCreateDocument() { + // Construct request + const request = { + parent, + document, + documentId, + }; + + // Run request + const response = await discoveryengineClient.createDocument(request); + console.log(response); + } + + callCreateDocument(); + // [END discoveryengine_v1_generated_DocumentService_CreateDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.delete_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.delete_document.js new file mode 100644 index 00000000000..07ea8d63758 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.delete_document.js @@ -0,0 +1,68 @@ +// Copyright 2023 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 discoveryengine_v1_generated_DocumentService_DeleteDocument_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 + * Document google.cloud.discoveryengine.v1.Document, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to delete the + * Document google.cloud.discoveryengine.v1.Document, regardless of whether + * or not it exists, a `PERMISSION_DENIED` error is returned. + * If the Document google.cloud.discoveryengine.v1.Document to delete does + * not exist, a `NOT_FOUND` error is returned. + */ + // const name = 'abc123' + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callDeleteDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await discoveryengineClient.deleteDocument(request); + console.log(response); + } + + callDeleteDocument(); + // [END discoveryengine_v1_generated_DocumentService_DeleteDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.get_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.get_document.js new file mode 100644 index 00000000000..c841cd21a70 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.get_document.js @@ -0,0 +1,68 @@ +// Copyright 2023 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 discoveryengine_v1_generated_DocumentService_GetDocument_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 + * Document google.cloud.discoveryengine.v1.Document, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to access the + * Document google.cloud.discoveryengine.v1.Document, regardless of whether + * or not it exists, a `PERMISSION_DENIED` error is returned. + * If the requested Document google.cloud.discoveryengine.v1.Document does + * not exist, a `NOT_FOUND` error is returned. + */ + // const name = 'abc123' + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callGetDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await discoveryengineClient.getDocument(request); + console.log(response); + } + + callGetDocument(); + // [END discoveryengine_v1_generated_DocumentService_GetDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.import_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.import_documents.js new file mode 100644 index 00000000000..575940b0b67 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.import_documents.js @@ -0,0 +1,133 @@ +// Copyright 2023 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 discoveryengine_v1_generated_DocumentService_ImportDocuments_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 Inline source for the input content for documents. + */ + // const inlineSource = {} + /** + * Cloud Storage location for the input content. + */ + // const gcsSource = {} + /** + * BigQuery input source. + */ + // const bigquerySource = {} + /** + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Requires create/update permission. + */ + // const parent = 'abc123' + /** + * The desired location of errors incurred during the Import. + */ + // const errorConfig = {} + /** + * The mode of reconciliation between existing documents and the documents to + * be imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Whether to automatically generate IDs for the documents if absent. + * If set to `true`, + * Document.id google.cloud.discoveryengine.v1.Document.id s are + * automatically generated based on the hash of the payload, where IDs may not + * be consistent during multiple imports. In which case + * ReconciliationMode.FULL google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.FULL + * is highly recommended to avoid duplicate contents. If unset or set to + * `false`, Document.id google.cloud.discoveryengine.v1.Document.id s have + * to be specified using + * id_field google.cloud.discoveryengine.v1.ImportDocumentsRequest.id_field, + * otherwises, documents without IDs will fail to be imported. + * Only set this field when using + * GcsSource google.cloud.discoveryengine.v1.GcsSource or + * BigQuerySource google.cloud.discoveryengine.v1.BigQuerySource, and when + * GcsSource.data_schema google.cloud.discoveryengine.v1.GcsSource.data_schema + * or + * BigQuerySource.data_schema google.cloud.discoveryengine.v1.BigQuerySource.data_schema + * is `custom`. Otherwise, an INVALID_ARGUMENT error is thrown. + */ + // const autoGenerateIds = true + /** + * The field in the Cloud Storage and BigQuery sources that indicates the + * unique IDs of the documents. + * For GcsSource google.cloud.discoveryengine.v1.GcsSource it is the key of + * the JSON field. For instance, `my_id` for JSON `{"my_id": "some_uuid"}`. + * For BigQuerySource google.cloud.discoveryengine.v1.BigQuerySource it is + * the column name of the BigQuery table where the unique ids are stored. + * The values of the JSON field or the BigQuery column will be used as the + * Document.id google.cloud.discoveryengine.v1.Document.id s. The JSON field + * or the BigQuery column must be of string type, and the values must be set + * as valid strings conform to RFC-1034 (https://tools.ietf.org/html/rfc1034) + * with 1-63 characters. Otherwise, documents without valid IDs will fail to + * be imported. + * Only set this field when using + * GcsSource google.cloud.discoveryengine.v1.GcsSource or + * BigQuerySource google.cloud.discoveryengine.v1.BigQuerySource, and when + * GcsSource.data_schema google.cloud.discoveryengine.v1.GcsSource.data_schema + * or + * BigQuerySource.data_schema google.cloud.discoveryengine.v1.BigQuerySource.data_schema + * is `custom`. And only set this field when + * auto_generate_ids google.cloud.discoveryengine.v1.ImportDocumentsRequest.auto_generate_ids + * is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. + * If it is unset, a default value `_id` is used when importing from the + * allowed data sources. + */ + // const idField = 'abc123' + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callImportDocuments() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await discoveryengineClient.importDocuments(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportDocuments(); + // [END discoveryengine_v1_generated_DocumentService_ImportDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.list_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.list_documents.js new file mode 100644 index 00000000000..35776f52b3b --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.list_documents.js @@ -0,0 +1,88 @@ +// Copyright 2023 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 discoveryengine_v1_generated_DocumentService_ListDocuments_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/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * If the caller does not have permission to list Documents s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Document google.cloud.discoveryengine.v1.Document 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 + * ListDocumentsResponse.next_page_token google.cloud.discoveryengine.v1.ListDocumentsResponse.next_page_token, + * received from a previous + * DocumentService.ListDocuments google.cloud.discoveryengine.v1.DocumentService.ListDocuments + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * DocumentService.ListDocuments google.cloud.discoveryengine.v1.DocumentService.ListDocuments + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callListDocuments() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await discoveryengineClient.listDocumentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListDocuments(); + // [END discoveryengine_v1_generated_DocumentService_ListDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.purge_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.purge_documents.js new file mode 100644 index 00000000000..e16e9efda70 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.purge_documents.js @@ -0,0 +1,75 @@ +// Copyright 2023 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 discoveryengine_v1_generated_DocumentService_PurgeDocuments_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 resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + */ + // const parent = 'abc123' + /** + * Required. Filter matching documents to purge. Only currently supported + * value is + * `*` (all items). + */ + // const filter = 'abc123' + /** + * Actually performs the purge. If `force` is set to false, return the + * expected purge count without deleting any documents. + */ + // const force = true + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callPurgeDocuments() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await discoveryengineClient.purgeDocuments(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeDocuments(); + // [END discoveryengine_v1_generated_DocumentService_PurgeDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.update_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.update_document.js new file mode 100644 index 00000000000..34a13e9d7db --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.update_document.js @@ -0,0 +1,74 @@ +// Copyright 2023 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(document) { + // [START discoveryengine_v1_generated_DocumentService_UpdateDocument_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 document to update/create. + * If the caller does not have permission to update the + * Document google.cloud.discoveryengine.v1.Document, regardless of whether + * or not it exists, a `PERMISSION_DENIED` error is returned. + * If the Document google.cloud.discoveryengine.v1.Document to update does + * not exist and + * allow_missing google.cloud.discoveryengine.v1.UpdateDocumentRequest.allow_missing + * is not set, a `NOT_FOUND` error is returned. + */ + // const document = {} + /** + * If set to true, and the + * Document google.cloud.discoveryengine.v1.Document is not found, a new + * Document google.cloud.discoveryengine.v1.Document will be created. + */ + // const allowMissing = true + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callUpdateDocument() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await discoveryengineClient.updateDocument(request); + console.log(response); + } + + callUpdateDocument(); + // [END discoveryengine_v1_generated_DocumentService_UpdateDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.create_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.create_schema.js new file mode 100644 index 00000000000..c3858db0cc9 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.create_schema.js @@ -0,0 +1,79 @@ +// Copyright 2023 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, schema, schemaId) { + // [START discoveryengine_v1_generated_SchemaService_CreateSchema_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 data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + */ + // const parent = 'abc123' + /** + * Required. The Schema google.cloud.discoveryengine.v1.Schema to create. + */ + // const schema = {} + /** + * Required. The ID to use for the + * Schema google.cloud.discoveryengine.v1.Schema, which will become the + * final component of the + * Schema.name google.cloud.discoveryengine.v1.Schema.name. + * This field should conform to + * RFC-1034 (https://tools.ietf.org/html/rfc1034) standard with a length + * limit of 63 characters. + */ + // const schemaId = 'abc123' + + // Imports the Discoveryengine library + const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new SchemaServiceClient(); + + async function callCreateSchema() { + // Construct request + const request = { + parent, + schema, + schemaId, + }; + + // Run request + const [operation] = await discoveryengineClient.createSchema(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateSchema(); + // [END discoveryengine_v1_generated_SchemaService_CreateSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.delete_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.delete_schema.js new file mode 100644 index 00000000000..453197cb6ac --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.delete_schema.js @@ -0,0 +1,63 @@ +// Copyright 2023 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 discoveryengine_v1_generated_SchemaService_DeleteSchema_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 full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + */ + // const name = 'abc123' + + // Imports the Discoveryengine library + const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new SchemaServiceClient(); + + async function callDeleteSchema() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await discoveryengineClient.deleteSchema(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteSchema(); + // [END discoveryengine_v1_generated_SchemaService_DeleteSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.get_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.get_schema.js new file mode 100644 index 00000000000..bead062baab --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.get_schema.js @@ -0,0 +1,62 @@ +// Copyright 2023 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 discoveryengine_v1_generated_SchemaService_GetSchema_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 full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + */ + // const name = 'abc123' + + // Imports the Discoveryengine library + const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new SchemaServiceClient(); + + async function callGetSchema() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await discoveryengineClient.getSchema(request); + console.log(response); + } + + callGetSchema(); + // [END discoveryengine_v1_generated_SchemaService_GetSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.list_schemas.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.list_schemas.js new file mode 100644 index 00000000000..892e642a95e --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.list_schemas.js @@ -0,0 +1,81 @@ +// Copyright 2023 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 discoveryengine_v1_generated_SchemaService_ListSchemas_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 data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + */ + // const parent = 'abc123' + /** + * The maximum number of Schema google.cloud.discoveryengine.v1.Schema s to + * return. The service may return fewer than this value. + * If unspecified, at most 100 + * Schema google.cloud.discoveryengine.v1.Schema s will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + */ + // const pageSize = 1234 + /** + * A page token, received from a previous + * SchemaService.ListSchemas google.cloud.discoveryengine.v1.SchemaService.ListSchemas + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SchemaService.ListSchemas google.cloud.discoveryengine.v1.SchemaService.ListSchemas + * must match the call that provided the page token. + */ + // const pageToken = 'abc123' + + // Imports the Discoveryengine library + const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new SchemaServiceClient(); + + async function callListSchemas() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await discoveryengineClient.listSchemasAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListSchemas(); + // [END discoveryengine_v1_generated_SchemaService_ListSchemas_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.update_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.update_schema.js new file mode 100644 index 00000000000..280538e4532 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.update_schema.js @@ -0,0 +1,68 @@ +// Copyright 2023 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(schema) { + // [START discoveryengine_v1_generated_SchemaService_UpdateSchema_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 Schema google.cloud.discoveryengine.v1.Schema to update. + */ + // const schema = {} + /** + * If set to true, and the Schema google.cloud.discoveryengine.v1.Schema is + * not found, a new Schema google.cloud.discoveryengine.v1.Schema will be + * created. In this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Discoveryengine library + const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new SchemaServiceClient(); + + async function callUpdateSchema() { + // Construct request + const request = { + schema, + }; + + // Run request + const [operation] = await discoveryengineClient.updateSchema(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateSchema(); + // [END discoveryengine_v1_generated_SchemaService_UpdateSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/search_service.search.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/search_service.search.js new file mode 100644 index 00000000000..58f51dba0ed --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/search_service.search.js @@ -0,0 +1,172 @@ +// Copyright 2023 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 discoveryengine_v1_generated_SearchService_Search_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 Search serving config, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + */ + // const servingConfig = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + */ + // const query = 'abc123' + /** + * Maximum number of Document google.cloud.discoveryengine.v1.Document s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 100. Values above 100 will be coerced to 100. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + */ + // const pageSize = 1234 + /** + * A page token received from a previous + * SearchService.Search google.cloud.discoveryengine.v1.SearchService.Search + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.discoveryengine.v1.SearchService.Search + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * Document google.cloud.discoveryengine.v1.Document s deemed by the API as + * relevant) in search results. This field is only considered if + * page_token google.cloud.discoveryengine.v1.SearchRequest.page_token is + * unset. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + */ + // const offset = 1234 + /** + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + */ + // const userInfo = {} + /** + * Additional search parameters. + * For public website search only, supported values are: + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + */ + // const params = 1234 + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + */ + // const queryExpansionSpec = {} + /** + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + */ + // const spellCorrectionSpec = {} + /** + * 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. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * UserEvent.user_pseudo_id google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id + * and + * CompleteQueryRequest.user_pseudo_id google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + */ + // const userPseudoId = 'abc123' + /** + * The content search spec that configs the desired behavior of content + * search. + */ + // const contentSearchSpec = {} + /** + * Whether to turn on safe search. This is only supported for + * ContentConfig.PUBLIC_WEBSITE . + */ + // const safeSearch = true + /** + * The user 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 userLabels = 1234 + + // Imports the Discoveryengine library + const {SearchServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + servingConfig, + }; + + // Run request + const iterable = await discoveryengineClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END discoveryengine_v1_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/snippet_metadata.google.cloud.discoveryengine.v1.json b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/snippet_metadata.google.cloud.discoveryengine.v1.json new file mode 100644 index 00000000000..5063fe7ede9 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/snippet_metadata.google.cloud.discoveryengine.v1.json @@ -0,0 +1,867 @@ +{ + "clientLibrary": { + "name": "nodejs-discoveryengine", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.discoveryengine.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "discoveryengine_v1_generated_CompletionService_CompleteQuery_async", + "title": "CompletionService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified user input with keyword suggestions.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 91, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.discoveryengine.v1.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "data_store", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "query_model", + "type": "TYPE_STRING" + }, + { + "name": "user_pseudo_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.discoveryengine.v1.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.discoveryengine.v1.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.discoveryengine.v1.CompletionService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_DocumentService_GetDocument_async", + "title": "CompletionService getDocument Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Document][google.cloud.discoveryengine.v1.Document].", + "canonical": true, + "file": "document_service.get_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDocument", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.GetDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1.Document", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" + }, + "method": { + "shortName": "GetDocument", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.GetDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_DocumentService_ListDocuments_async", + "title": "CompletionService listDocuments Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s.", + "canonical": true, + "file": "document_service.list_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDocuments", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.ListDocuments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1.ListDocumentsResponse", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" + }, + "method": { + "shortName": "ListDocuments", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.ListDocuments", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_DocumentService_CreateDocument_async", + "title": "CompletionService createDocument Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Document][google.cloud.discoveryengine.v1.Document].", + "canonical": true, + "file": "document_service.create_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDocument", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.CreateDocument", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "document", + "type": ".google.cloud.discoveryengine.v1.Document" + }, + { + "name": "document_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1.Document", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" + }, + "method": { + "shortName": "CreateDocument", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.CreateDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_DocumentService_UpdateDocument_async", + "title": "CompletionService updateDocument Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Document][google.cloud.discoveryengine.v1.Document].", + "canonical": true, + "file": "document_service.update_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDocument", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.UpdateDocument", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.discoveryengine.v1.Document" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.discoveryengine.v1.Document", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" + }, + "method": { + "shortName": "UpdateDocument", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.UpdateDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_DocumentService_DeleteDocument_async", + "title": "CompletionService deleteDocument Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Document][google.cloud.discoveryengine.v1.Document].", + "canonical": true, + "file": "document_service.delete_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDocument", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.DeleteDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" + }, + "method": { + "shortName": "DeleteDocument", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.DeleteDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_DocumentService_ImportDocuments_async", + "title": "CompletionService importDocuments Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Document][google.cloud.discoveryengine.v1.Document]s. Request processing may be synchronous. Non-existing items will be created. Note: It is possible for a subset of the [Document][google.cloud.discoveryengine.v1.Document]s to be successfully updated.", + "canonical": true, + "file": "document_service.import_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 125, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportDocuments", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.ImportDocuments", + "async": true, + "parameters": [ + { + "name": "inline_source", + "type": ".google.cloud.discoveryengine.v1.ImportDocumentsRequest.InlineSource" + }, + { + "name": "gcs_source", + "type": ".google.cloud.discoveryengine.v1.GcsSource" + }, + { + "name": "bigquery_source", + "type": ".google.cloud.discoveryengine.v1.BigQuerySource" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "error_config", + "type": ".google.cloud.discoveryengine.v1.ImportErrorConfig" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode" + }, + { + "name": "auto_generate_ids", + "type": "TYPE_BOOL" + }, + { + "name": "id_field", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" + }, + "method": { + "shortName": "ImportDocuments", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.ImportDocuments", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_DocumentService_PurgeDocuments_async", + "title": "CompletionService purgeDocuments Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes all selected [Document][google.cloud.discoveryengine.v1.Document]s in a branch. This process is asynchronous. Depending on the number of [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this operation can take hours to complete. Before the delete operation completes, some [Document][google.cloud.discoveryengine.v1.Document]s might still be returned by [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] or [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments]. To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, set [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force] to false.", + "canonical": true, + "file": "document_service.purge_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeDocuments", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.PurgeDocuments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" + }, + "method": { + "shortName": "PurgeDocuments", + "fullName": "google.cloud.discoveryengine.v1.DocumentService.PurgeDocuments", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_SchemaService_GetSchema_async", + "title": "CompletionService getSchema Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Schema][google.cloud.discoveryengine.v1.Schema].", + "canonical": true, + "file": "schema_service.get_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetSchema", + "fullName": "google.cloud.discoveryengine.v1.SchemaService.GetSchema", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1.Schema", + "client": { + "shortName": "SchemaServiceClient", + "fullName": "google.cloud.discoveryengine.v1.SchemaServiceClient" + }, + "method": { + "shortName": "GetSchema", + "fullName": "google.cloud.discoveryengine.v1.SchemaService.GetSchema", + "service": { + "shortName": "SchemaService", + "fullName": "google.cloud.discoveryengine.v1.SchemaService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_SchemaService_ListSchemas_async", + "title": "CompletionService listSchemas Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s.", + "canonical": true, + "file": "schema_service.list_schemas.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListSchemas", + "fullName": "google.cloud.discoveryengine.v1.SchemaService.ListSchemas", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1.ListSchemasResponse", + "client": { + "shortName": "SchemaServiceClient", + "fullName": "google.cloud.discoveryengine.v1.SchemaServiceClient" + }, + "method": { + "shortName": "ListSchemas", + "fullName": "google.cloud.discoveryengine.v1.SchemaService.ListSchemas", + "service": { + "shortName": "SchemaService", + "fullName": "google.cloud.discoveryengine.v1.SchemaService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_SchemaService_CreateSchema_async", + "title": "CompletionService createSchema Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Schema][google.cloud.discoveryengine.v1.Schema].", + "canonical": true, + "file": "schema_service.create_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSchema", + "fullName": "google.cloud.discoveryengine.v1.SchemaService.CreateSchema", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "schema", + "type": ".google.cloud.discoveryengine.v1.Schema" + }, + { + "name": "schema_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SchemaServiceClient", + "fullName": "google.cloud.discoveryengine.v1.SchemaServiceClient" + }, + "method": { + "shortName": "CreateSchema", + "fullName": "google.cloud.discoveryengine.v1.SchemaService.CreateSchema", + "service": { + "shortName": "SchemaService", + "fullName": "google.cloud.discoveryengine.v1.SchemaService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_SchemaService_UpdateSchema_async", + "title": "CompletionService updateSchema Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Schema][google.cloud.discoveryengine.v1.Schema].", + "canonical": true, + "file": "schema_service.update_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateSchema", + "fullName": "google.cloud.discoveryengine.v1.SchemaService.UpdateSchema", + "async": true, + "parameters": [ + { + "name": "schema", + "type": ".google.cloud.discoveryengine.v1.Schema" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SchemaServiceClient", + "fullName": "google.cloud.discoveryengine.v1.SchemaServiceClient" + }, + "method": { + "shortName": "UpdateSchema", + "fullName": "google.cloud.discoveryengine.v1.SchemaService.UpdateSchema", + "service": { + "shortName": "SchemaService", + "fullName": "google.cloud.discoveryengine.v1.SchemaService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_SchemaService_DeleteSchema_async", + "title": "CompletionService deleteSchema Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Schema][google.cloud.discoveryengine.v1.Schema].", + "canonical": true, + "file": "schema_service.delete_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteSchema", + "fullName": "google.cloud.discoveryengine.v1.SchemaService.DeleteSchema", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SchemaServiceClient", + "fullName": "google.cloud.discoveryengine.v1.SchemaServiceClient" + }, + "method": { + "shortName": "DeleteSchema", + "fullName": "google.cloud.discoveryengine.v1.SchemaService.DeleteSchema", + "service": { + "shortName": "SchemaService", + "fullName": "google.cloud.discoveryengine.v1.SchemaService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_SearchService_Search_async", + "title": "CompletionService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 164, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.discoveryengine.v1.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "user_info", + "type": ".google.cloud.discoveryengine.v1.UserInfo" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec" + }, + { + "name": "spell_correction_spec", + "type": ".google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec" + }, + { + "name": "user_pseudo_id", + "type": "TYPE_STRING" + }, + { + "name": "content_search_spec", + "type": ".google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec" + }, + { + "name": "safe_search", + "type": "TYPE_BOOL" + }, + { + "name": "user_labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.discoveryengine.v1.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.discoveryengine.v1.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.discoveryengine.v1.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.discoveryengine.v1.SearchService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_UserEventService_WriteUserEvent_async", + "title": "CompletionService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.discoveryengine.v1.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.discoveryengine.v1.UserEvent" + } + ], + "resultType": ".google.cloud.discoveryengine.v1.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.discoveryengine.v1.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.discoveryengine.v1.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.discoveryengine.v1.UserEventService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_UserEventService_CollectUserEvent_async", + "title": "CompletionService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Discovery Engine API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.discoveryengine.v1.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.discoveryengine.v1.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.discoveryengine.v1.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.discoveryengine.v1.UserEventService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1_generated_UserEventService_ImportUserEvents_async", + "title": "CompletionService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.discoveryengine.v1.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "inline_source", + "type": ".google.cloud.discoveryengine.v1.ImportUserEventsRequest.InlineSource" + }, + { + "name": "gcs_source", + "type": ".google.cloud.discoveryengine.v1.GcsSource" + }, + { + "name": "bigquery_source", + "type": ".google.cloud.discoveryengine.v1.BigQuerySource" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "error_config", + "type": ".google.cloud.discoveryengine.v1.ImportErrorConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.discoveryengine.v1.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.discoveryengine.v1.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.discoveryengine.v1.UserEventService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.collect_user_event.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.collect_user_event.js new file mode 100644 index 00000000000..3be0b538b16 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.collect_user_event.js @@ -0,0 +1,81 @@ +// Copyright 2023 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 discoveryengine_v1_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 DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + */ + // 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 Discoveryengine library + const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await discoveryengineClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END discoveryengine_v1_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.import_user_events.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.import_user_events.js new file mode 100644 index 00000000000..a5e95b91695 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.import_user_events.js @@ -0,0 +1,83 @@ +// Copyright 2023 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(inlineSource, gcsSource, bigquerySource, parent) { + // [START discoveryengine_v1_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. The Inline source for the input content for UserEvents. + */ + // const inlineSource = {} + /** + * Required. Cloud Storage location for the input content. + */ + // const gcsSource = {} + /** + * Required. BigQuery input source. + */ + // const bigquerySource = {} + /** + * Required. Parent DataStore resource name, of the form + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + */ + // const parent = 'abc123' + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorConfig = {} + + // Imports the Discoveryengine library + const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + inlineSource, + gcsSource, + bigquerySource, + parent, + }; + + // Run request + const [operation] = await discoveryengineClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END discoveryengine_v1_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.write_user_event.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.write_user_event.js new file mode 100644 index 00000000000..c55a9f3aefb --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.write_user_event.js @@ -0,0 +1,67 @@ +// Copyright 2023 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 discoveryengine_v1_generated_UserEventService_WriteUserEvent_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 DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Discoveryengine library + const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1; + + // Instantiates a client + const discoveryengineClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await discoveryengineClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END discoveryengine_v1_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/index.ts new file mode 100644 index 00000000000..27888094c09 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/index.ts @@ -0,0 +1,33 @@ +// Copyright 2023 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. ** + +import * as v1 from './v1'; +const CompletionServiceClient = v1.CompletionServiceClient; +type CompletionServiceClient = v1.CompletionServiceClient; +const DocumentServiceClient = v1.DocumentServiceClient; +type DocumentServiceClient = v1.DocumentServiceClient; +const SchemaServiceClient = v1.SchemaServiceClient; +type SchemaServiceClient = v1.SchemaServiceClient; +const SearchServiceClient = v1.SearchServiceClient; +type SearchServiceClient = v1.SearchServiceClient; +const UserEventServiceClient = v1.UserEventServiceClient; +type UserEventServiceClient = v1.UserEventServiceClient; +export {v1, CompletionServiceClient, DocumentServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient}; +export default {v1, CompletionServiceClient, DocumentServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client.ts new file mode 100644 index 00000000000..7e3614d4f77 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client.ts @@ -0,0 +1,854 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for Auto-Completion. + * @class + * @memberof v1 + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CompletionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' + ), + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1.CompletionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1.CompletionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1.CompletionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const completionServiceStubMethods = + ['completeQuery']; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Completes the specified user input with keyword suggestions. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.dataStore + * Required. The parent data store resource name for which the completion is + * performed, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store`. + * @param {string} request.query + * Required. The typeahead input used to fetch suggestions. Maximum length is + * 128 characters. + * @param {string} request.queryModel + * Selects data model of query suggestions for serving. Currently supported + * values: + * + * * `document` - Using suggestions generated from user-imported documents. + * * `search-history` - Using suggestions generated from the past history of + * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} + * API calls. Do not use it when there is no traffic for Search API. + * * `user-event` - Using suggestions generated from user-imported search + * events. + * + * Default values: + * + * * `document` is the default model for regular dataStores. + * * `search-history` is the default model for + * {@link google.cloud.discoveryengine.v1.IndustryVertical.SITE_SEARCH|IndustryVertical.SITE_SEARCH} + * dataStores. + * @param {string} request.userPseudoId + * 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. + * + * This field should NOT have a fixed value such as `unknown_visitor`. + * + * This should be the same identifier as + * {@link google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} + * and + * {@link google.cloud.discoveryengine.v1.SearchRequest.user_pseudo_id|SearchRequest.user_pseudo_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.CompleteQueryResponse | CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/completion_service.complete_query.js + * region_tag:discoveryengine_v1_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|undefined, {}|undefined + ]>; + completeQuery( + request: protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request: protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request?: protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'data_store': request.dataStore ?? '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationDataStorePath(project:string,location:string,dataStore:string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client_config.json new file mode 100644 index 00000000000..8cf2b18b202 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client_config.json @@ -0,0 +1,43 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1.CompletionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "unavailable", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_proto_list.json new file mode 100644 index 00000000000..60d54073cfa --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_proto_list.json @@ -0,0 +1,13 @@ +[ + "../../protos/google/cloud/discoveryengine/v1/common.proto", + "../../protos/google/cloud/discoveryengine/v1/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1/document.proto", + "../../protos/google/cloud/discoveryengine/v1/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1/schema.proto", + "../../protos/google/cloud/discoveryengine/v1/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client.ts new file mode 100644 index 00000000000..a09f0de16be --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client.ts @@ -0,0 +1,1839 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/document_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './document_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting {@link google.cloud.discoveryengine.v1.Document|Document} + * information of the customer's website. + * @class + * @memberof v1 + */ +export class DocumentServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + documentServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DocumentServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new DocumentServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DocumentServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}' + ), + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listDocuments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*}/operations',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*}/operations',},{get: '/v1/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importDocumentsResponse = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.ImportDocumentsResponse') as gax.protobuf.Type; + const importDocumentsMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.ImportDocumentsMetadata') as gax.protobuf.Type; + const purgeDocumentsResponse = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.PurgeDocumentsResponse') as gax.protobuf.Type; + const purgeDocumentsMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.PurgeDocumentsMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importDocumentsResponse.decode.bind(importDocumentsResponse), + importDocumentsMetadata.decode.bind(importDocumentsMetadata)), + purgeDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeDocumentsResponse.decode.bind(purgeDocumentsResponse), + purgeDocumentsMetadata.decode.bind(purgeDocumentsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1.DocumentService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.documentServiceStub) { + return this.documentServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1.DocumentService. + this.documentServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1.DocumentService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1.DocumentService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const documentServiceStubMethods = + ['getDocument', 'listDocuments', 'createDocument', 'updateDocument', 'deleteDocument', 'importDocuments', 'purgeDocuments']; + for (const methodName of documentServiceStubMethods) { + const callPromise = this.documentServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.documentServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets a {@link google.cloud.discoveryengine.v1.Document|Document}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.discoveryengine.v1.Document|Document}, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * + * If the caller does not have permission to access the + * {@link google.cloud.discoveryengine.v1.Document|Document}, regardless of whether + * or not it exists, a `PERMISSION_DENIED` error is returned. + * + * If the requested {@link google.cloud.discoveryengine.v1.Document|Document} does + * not exist, a `NOT_FOUND` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.Document | Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_service.get_document.js + * region_tag:discoveryengine_v1_generated_DocumentService_GetDocument_async + */ + getDocument( + request?: protos.google.cloud.discoveryengine.v1.IGetDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|undefined, {}|undefined + ]>; + getDocument( + request: protos.google.cloud.discoveryengine.v1.IGetDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): void; + getDocument( + request: protos.google.cloud.discoveryengine.v1.IGetDocumentRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): void; + getDocument( + request?: protos.google.cloud.discoveryengine.v1.IGetDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDocument(request, options, callback); + } +/** + * Creates a {@link google.cloud.discoveryengine.v1.Document|Document}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * @param {google.cloud.discoveryengine.v1.Document} request.document + * Required. The {@link google.cloud.discoveryengine.v1.Document|Document} to + * create. + * @param {string} request.documentId + * Required. The ID to use for the + * {@link google.cloud.discoveryengine.v1.Document|Document}, which will become the + * final component of the + * {@link google.cloud.discoveryengine.v1.Document.name|Document.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.discoveryengine.v1.Document|Document}, regardless of whether + * or not it exists, a `PERMISSION_DENIED` error is returned. + * + * This field must be unique among all + * {@link google.cloud.discoveryengine.v1.Document|Document}s with the same + * {@link google.cloud.discoveryengine.v1.CreateDocumentRequest.parent|parent}. + * Otherwise, an `ALREADY_EXISTS` error is returned. + * + * This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.Document | Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_service.create_document.js + * region_tag:discoveryengine_v1_generated_DocumentService_CreateDocument_async + */ + createDocument( + request?: protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|undefined, {}|undefined + ]>; + createDocument( + request: protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): void; + createDocument( + request: protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): void; + createDocument( + request?: protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createDocument(request, options, callback); + } +/** + * Updates a {@link google.cloud.discoveryengine.v1.Document|Document}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.discoveryengine.v1.Document} request.document + * Required. The document to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.discoveryengine.v1.Document|Document}, regardless of whether + * or not it exists, a `PERMISSION_DENIED` error is returned. + * + * If the {@link google.cloud.discoveryengine.v1.Document|Document} to update does + * not exist and + * {@link google.cloud.discoveryengine.v1.UpdateDocumentRequest.allow_missing|allow_missing} + * is not set, a `NOT_FOUND` error is returned. + * @param {boolean} request.allowMissing + * If set to true, and the + * {@link google.cloud.discoveryengine.v1.Document|Document} is not found, a new + * {@link google.cloud.discoveryengine.v1.Document|Document} will be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.Document | Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_service.update_document.js + * region_tag:discoveryengine_v1_generated_DocumentService_UpdateDocument_async + */ + updateDocument( + request?: protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|undefined, {}|undefined + ]>; + updateDocument( + request: protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): void; + updateDocument( + request: protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): void; + updateDocument( + request?: protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1.IDocument, + protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'document.name': request.document!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateDocument(request, options, callback); + } +/** + * Deletes a {@link google.cloud.discoveryengine.v1.Document|Document}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.discoveryengine.v1.Document|Document}, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.discoveryengine.v1.Document|Document}, regardless of whether + * or not it exists, a `PERMISSION_DENIED` error is returned. + * + * If the {@link google.cloud.discoveryengine.v1.Document|Document} to delete does + * not exist, a `NOT_FOUND` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.protobuf.Empty | Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_service.delete_document.js + * region_tag:discoveryengine_v1_generated_DocumentService_DeleteDocument_async + */ + deleteDocument( + request?: protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|undefined, {}|undefined + ]>; + deleteDocument( + request: protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): void; + deleteDocument( + request: protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): void; + deleteDocument( + request?: protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteDocument(request, options, callback); + } + +/** + * Bulk import of multiple + * {@link google.cloud.discoveryengine.v1.Document|Document}s. Request processing + * may be synchronous. Non-existing items will be created. + * + * Note: It is possible for a subset of the + * {@link google.cloud.discoveryengine.v1.Document|Document}s to be successfully + * updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.discoveryengine.v1.ImportDocumentsRequest.InlineSource} request.inlineSource + * The Inline source for the input content for documents. + * @param {google.cloud.discoveryengine.v1.GcsSource} request.gcsSource + * Cloud Storage location for the input content. + * @param {google.cloud.discoveryengine.v1.BigQuerySource} request.bigquerySource + * BigQuery input source. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Requires create/update permission. + * @param {google.cloud.discoveryengine.v1.ImportErrorConfig} request.errorConfig + * The desired location of errors incurred during the Import. + * @param {google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing documents and the documents to + * be imported. Defaults to + * {@link google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {boolean} request.autoGenerateIds + * Whether to automatically generate IDs for the documents if absent. + * + * If set to `true`, + * {@link google.cloud.discoveryengine.v1.Document.id|Document.id}s are + * automatically generated based on the hash of the payload, where IDs may not + * be consistent during multiple imports. In which case + * {@link google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.FULL|ReconciliationMode.FULL} + * is highly recommended to avoid duplicate contents. If unset or set to + * `false`, {@link google.cloud.discoveryengine.v1.Document.id|Document.id}s have + * to be specified using + * {@link google.cloud.discoveryengine.v1.ImportDocumentsRequest.id_field|id_field}, + * otherwises, documents without IDs will fail to be imported. + * + * Only set this field when using + * {@link google.cloud.discoveryengine.v1.GcsSource|GcsSource} or + * {@link google.cloud.discoveryengine.v1.BigQuerySource|BigQuerySource}, and when + * {@link google.cloud.discoveryengine.v1.GcsSource.data_schema|GcsSource.data_schema} + * or + * {@link google.cloud.discoveryengine.v1.BigQuerySource.data_schema|BigQuerySource.data_schema} + * is `custom`. Otherwise, an INVALID_ARGUMENT error is thrown. + * @param {string} request.idField + * The field in the Cloud Storage and BigQuery sources that indicates the + * unique IDs of the documents. + * + * For {@link google.cloud.discoveryengine.v1.GcsSource|GcsSource} it is the key of + * the JSON field. For instance, `my_id` for JSON `{"my_id": "some_uuid"}`. + * For {@link google.cloud.discoveryengine.v1.BigQuerySource|BigQuerySource} it is + * the column name of the BigQuery table where the unique ids are stored. + * + * The values of the JSON field or the BigQuery column will be used as the + * {@link google.cloud.discoveryengine.v1.Document.id|Document.id}s. The JSON field + * or the BigQuery column must be of string type, and the values must be set + * as valid strings conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * with 1-63 characters. Otherwise, documents without valid IDs will fail to + * be imported. + * + * Only set this field when using + * {@link google.cloud.discoveryengine.v1.GcsSource|GcsSource} or + * {@link google.cloud.discoveryengine.v1.BigQuerySource|BigQuerySource}, and when + * {@link google.cloud.discoveryengine.v1.GcsSource.data_schema|GcsSource.data_schema} + * or + * {@link google.cloud.discoveryengine.v1.BigQuerySource.data_schema|BigQuerySource.data_schema} + * is `custom`. And only set this field when + * {@link google.cloud.discoveryengine.v1.ImportDocumentsRequest.auto_generate_ids|auto_generate_ids} + * is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. + * + * If it is unset, a default value `_id` is used when importing from the + * allowed data sources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_service.import_documents.js + * region_tag:discoveryengine_v1_generated_DocumentService_ImportDocuments_async + */ + importDocuments( + request?: protos.google.cloud.discoveryengine.v1.IImportDocumentsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importDocuments( + request: protos.google.cloud.discoveryengine.v1.IImportDocumentsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importDocuments( + request: protos.google.cloud.discoveryengine.v1.IImportDocumentsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importDocuments( + request?: protos.google.cloud.discoveryengine.v1.IImportDocumentsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importDocuments(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importDocuments()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_service.import_documents.js + * region_tag:discoveryengine_v1_generated_DocumentService_ImportDocuments_async + */ + async checkImportDocumentsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importDocuments, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Permanently deletes all selected + * {@link google.cloud.discoveryengine.v1.Document|Document}s in a branch. + * + * This process is asynchronous. Depending on the number of + * {@link google.cloud.discoveryengine.v1.Document|Document}s to be deleted, this + * operation can take hours to complete. Before the delete operation + * completes, some {@link google.cloud.discoveryengine.v1.Document|Document}s might + * still be returned by + * {@link google.cloud.discoveryengine.v1.DocumentService.GetDocument|DocumentService.GetDocument} + * or + * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments}. + * + * To get a list of the {@link google.cloud.discoveryengine.v1.Document|Document}s + * to be deleted, set + * {@link google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force|PurgeDocumentsRequest.force} + * to false. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * @param {string} request.filter + * Required. Filter matching documents to purge. Only currently supported + * value is + * `*` (all items). + * @param {boolean} request.force + * Actually performs the purge. If `force` is set to false, return the + * expected purge count without deleting any documents. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_service.purge_documents.js + * region_tag:discoveryengine_v1_generated_DocumentService_PurgeDocuments_async + */ + purgeDocuments( + request?: protos.google.cloud.discoveryengine.v1.IPurgeDocumentsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeDocuments( + request: protos.google.cloud.discoveryengine.v1.IPurgeDocumentsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeDocuments( + request: protos.google.cloud.discoveryengine.v1.IPurgeDocumentsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeDocuments( + request?: protos.google.cloud.discoveryengine.v1.IPurgeDocumentsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.purgeDocuments(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeDocuments()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_service.purge_documents.js + * region_tag:discoveryengine_v1_generated_DocumentService_PurgeDocuments_async + */ + async checkPurgeDocumentsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeDocuments, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Gets a list of {@link google.cloud.discoveryengine.v1.Document|Document}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * + * If the caller does not have permission to list {@link |Documents}s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}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. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.discoveryengine.v1.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link google.cloud.discoveryengine.v1.Document | Document}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDocuments( + request?: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1.IDocument[], + protos.google.cloud.discoveryengine.v1.IListDocumentsRequest|null, + protos.google.cloud.discoveryengine.v1.IListDocumentsResponse + ]>; + listDocuments( + request: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, + protos.google.cloud.discoveryengine.v1.IListDocumentsResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.IDocument>): void; + listDocuments( + request: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, + protos.google.cloud.discoveryengine.v1.IListDocumentsResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.IDocument>): void; + listDocuments( + request?: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, + protos.google.cloud.discoveryengine.v1.IListDocumentsResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.IDocument>, + callback?: PaginationCallback< + protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, + protos.google.cloud.discoveryengine.v1.IListDocumentsResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.IDocument>): + Promise<[ + protos.google.cloud.discoveryengine.v1.IDocument[], + protos.google.cloud.discoveryengine.v1.IListDocumentsRequest|null, + protos.google.cloud.discoveryengine.v1.IListDocumentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listDocuments(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * + * If the caller does not have permission to list {@link |Documents}s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}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. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.discoveryengine.v1.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1.Document | Document} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDocumentsStream( + request?: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.createStream( + this.innerApiCalls.listDocuments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listDocuments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * + * If the caller does not have permission to list {@link |Documents}s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}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. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.discoveryengine.v1.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.discoveryengine.v1.Document | Document}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/document_service.list_documents.js + * region_tag:discoveryengine_v1_generated_DocumentService_ListDocuments_async + */ + listDocumentsAsync( + request?: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.asyncIterate( + this.innerApiCalls['listDocuments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchPath(project:string,location:string,collection:string,dataStore:string,branch:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).branch; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchPath(project:string,location:string,dataStore:string,branch:string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).branch; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.documentServiceStub && !this._terminated) { + return this.documentServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client_config.json new file mode 100644 index 00000000000..cb11ed6b90a --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client_config.json @@ -0,0 +1,82 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1.DocumentService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "GetDocument": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListDocuments": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "CreateDocument": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateDocument": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "DeleteDocument": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ImportDocuments": { + "timeout_millis": 300000, + "retry_codes_name": "unavailable", + "retry_params_name": "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876" + }, + "PurgeDocuments": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_proto_list.json new file mode 100644 index 00000000000..60d54073cfa --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_proto_list.json @@ -0,0 +1,13 @@ +[ + "../../protos/google/cloud/discoveryengine/v1/common.proto", + "../../protos/google/cloud/discoveryengine/v1/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1/document.proto", + "../../protos/google/cloud/discoveryengine/v1/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1/schema.proto", + "../../protos/google/cloud/discoveryengine/v1/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..4ca67f3204b --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/gapic_metadata.json @@ -0,0 +1,261 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.discoveryengine.v1", + "libraryPackage": "@google-cloud/discoveryengine", + "services": { + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + } + } + } + } + }, + "DocumentService": { + "clients": { + "grpc": { + "libraryClient": "DocumentServiceClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "ImportDocuments": { + "methods": [ + "importDocuments" + ] + }, + "PurgeDocuments": { + "methods": [ + "purgeDocuments" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentServiceClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "ImportDocuments": { + "methods": [ + "importDocuments" + ] + }, + "PurgeDocuments": { + "methods": [ + "purgeDocuments" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + } + } + } + } + }, + "SchemaService": { + "clients": { + "grpc": { + "libraryClient": "SchemaServiceClient", + "rpcs": { + "GetSchema": { + "methods": [ + "getSchema" + ] + }, + "CreateSchema": { + "methods": [ + "createSchema" + ] + }, + "UpdateSchema": { + "methods": [ + "updateSchema" + ] + }, + "DeleteSchema": { + "methods": [ + "deleteSchema" + ] + }, + "ListSchemas": { + "methods": [ + "listSchemas", + "listSchemasStream", + "listSchemasAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SchemaServiceClient", + "rpcs": { + "GetSchema": { + "methods": [ + "getSchema" + ] + }, + "CreateSchema": { + "methods": [ + "createSchema" + ] + }, + "UpdateSchema": { + "methods": [ + "updateSchema" + ] + }, + "DeleteSchema": { + "methods": [ + "deleteSchema" + ] + }, + "ListSchemas": { + "methods": [ + "listSchemas", + "listSchemasStream", + "listSchemasAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/index.ts new file mode 100644 index 00000000000..ecca0c5d193 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/index.ts @@ -0,0 +1,23 @@ +// Copyright 2023 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. ** + +export {CompletionServiceClient} from './completion_service_client'; +export {DocumentServiceClient} from './document_service_client'; +export {SchemaServiceClient} from './schema_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client.ts new file mode 100644 index 00000000000..6c475dd0ec3 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client.ts @@ -0,0 +1,1550 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/schema_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './schema_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for managing {@link google.cloud.discoveryengine.v1.Schema|Schema}s. + * @class + * @memberof v1 + */ +export class SchemaServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + schemaServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SchemaServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SchemaServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SchemaServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' + ), + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listSchemas: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'schemas') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*}/operations',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*}/operations',},{get: '/v1/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createSchemaResponse = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.Schema') as gax.protobuf.Type; + const createSchemaMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.CreateSchemaMetadata') as gax.protobuf.Type; + const updateSchemaResponse = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.Schema') as gax.protobuf.Type; + const updateSchemaMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.UpdateSchemaMetadata') as gax.protobuf.Type; + const deleteSchemaResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteSchemaMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.DeleteSchemaMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createSchema: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createSchemaResponse.decode.bind(createSchemaResponse), + createSchemaMetadata.decode.bind(createSchemaMetadata)), + updateSchema: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateSchemaResponse.decode.bind(updateSchemaResponse), + updateSchemaMetadata.decode.bind(updateSchemaMetadata)), + deleteSchema: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteSchemaResponse.decode.bind(deleteSchemaResponse), + deleteSchemaMetadata.decode.bind(deleteSchemaMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1.SchemaService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.schemaServiceStub) { + return this.schemaServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1.SchemaService. + this.schemaServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1.SchemaService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1.SchemaService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const schemaServiceStubMethods = + ['getSchema', 'listSchemas', 'createSchema', 'updateSchema', 'deleteSchema']; + for (const methodName of schemaServiceStubMethods) { + const callPromise = this.schemaServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.schemaServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets a {@link google.cloud.discoveryengine.v1.Schema|Schema}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.Schema | Schema}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/schema_service.get_schema.js + * region_tag:discoveryengine_v1_generated_SchemaService_GetSchema_async + */ + getSchema( + request?: protos.google.cloud.discoveryengine.v1.IGetSchemaRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1.ISchema, + protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|undefined, {}|undefined + ]>; + getSchema( + request: protos.google.cloud.discoveryengine.v1.IGetSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1.ISchema, + protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|null|undefined, + {}|null|undefined>): void; + getSchema( + request: protos.google.cloud.discoveryengine.v1.IGetSchemaRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1.ISchema, + protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|null|undefined, + {}|null|undefined>): void; + getSchema( + request?: protos.google.cloud.discoveryengine.v1.IGetSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1.ISchema, + protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1.ISchema, + protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1.ISchema, + protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getSchema(request, options, callback); + } + +/** + * Creates a {@link google.cloud.discoveryengine.v1.Schema|Schema}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {google.cloud.discoveryengine.v1.Schema} request.schema + * Required. The {@link google.cloud.discoveryengine.v1.Schema|Schema} to create. + * @param {string} request.schemaId + * Required. The ID to use for the + * {@link google.cloud.discoveryengine.v1.Schema|Schema}, which will become the + * final component of the + * {@link google.cloud.discoveryengine.v1.Schema.name|Schema.name}. + * + * This field should conform to + * [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length + * limit of 63 characters. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/schema_service.create_schema.js + * region_tag:discoveryengine_v1_generated_SchemaService_CreateSchema_async + */ + createSchema( + request?: protos.google.cloud.discoveryengine.v1.ICreateSchemaRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createSchema( + request: protos.google.cloud.discoveryengine.v1.ICreateSchemaRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createSchema( + request: protos.google.cloud.discoveryengine.v1.ICreateSchemaRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createSchema( + request?: protos.google.cloud.discoveryengine.v1.ICreateSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createSchema(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createSchema()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/schema_service.create_schema.js + * region_tag:discoveryengine_v1_generated_SchemaService_CreateSchema_async + */ + async checkCreateSchemaProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createSchema, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a {@link google.cloud.discoveryengine.v1.Schema|Schema}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.discoveryengine.v1.Schema} request.schema + * Required. The {@link google.cloud.discoveryengine.v1.Schema|Schema} to update. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.discoveryengine.v1.Schema|Schema} is + * not found, a new {@link google.cloud.discoveryengine.v1.Schema|Schema} will be + * created. In this situation, `update_mask` is ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/schema_service.update_schema.js + * region_tag:discoveryengine_v1_generated_SchemaService_UpdateSchema_async + */ + updateSchema( + request?: protos.google.cloud.discoveryengine.v1.IUpdateSchemaRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateSchema( + request: protos.google.cloud.discoveryengine.v1.IUpdateSchemaRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateSchema( + request: protos.google.cloud.discoveryengine.v1.IUpdateSchemaRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateSchema( + request?: protos.google.cloud.discoveryengine.v1.IUpdateSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'schema.name': request.schema!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateSchema(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateSchema()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/schema_service.update_schema.js + * region_tag:discoveryengine_v1_generated_SchemaService_UpdateSchema_async + */ + async checkUpdateSchemaProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateSchema, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a {@link google.cloud.discoveryengine.v1.Schema|Schema}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/schema_service.delete_schema.js + * region_tag:discoveryengine_v1_generated_SchemaService_DeleteSchema_async + */ + deleteSchema( + request?: protos.google.cloud.discoveryengine.v1.IDeleteSchemaRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteSchema( + request: protos.google.cloud.discoveryengine.v1.IDeleteSchemaRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteSchema( + request: protos.google.cloud.discoveryengine.v1.IDeleteSchemaRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteSchema( + request?: protos.google.cloud.discoveryengine.v1.IDeleteSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteSchema(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteSchema()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/schema_service.delete_schema.js + * region_tag:discoveryengine_v1_generated_SchemaService_DeleteSchema_async + */ + async checkDeleteSchemaProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteSchema, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Gets a list of {@link google.cloud.discoveryengine.v1.Schema|Schema}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {number} request.pageSize + * The maximum number of {@link google.cloud.discoveryengine.v1.Schema|Schema}s to + * return. The service may return fewer than this value. + * + * If unspecified, at most 100 + * {@link google.cloud.discoveryengine.v1.Schema|Schema}s will be returned. + * + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} + * must match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link google.cloud.discoveryengine.v1.Schema | Schema}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSchemasAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listSchemas( + request?: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1.ISchema[], + protos.google.cloud.discoveryengine.v1.IListSchemasRequest|null, + protos.google.cloud.discoveryengine.v1.IListSchemasResponse + ]>; + listSchemas( + request: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1.IListSchemasRequest, + protos.google.cloud.discoveryengine.v1.IListSchemasResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.ISchema>): void; + listSchemas( + request: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1.IListSchemasRequest, + protos.google.cloud.discoveryengine.v1.IListSchemasResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.ISchema>): void; + listSchemas( + request?: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.discoveryengine.v1.IListSchemasRequest, + protos.google.cloud.discoveryengine.v1.IListSchemasResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.ISchema>, + callback?: PaginationCallback< + protos.google.cloud.discoveryengine.v1.IListSchemasRequest, + protos.google.cloud.discoveryengine.v1.IListSchemasResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.ISchema>): + Promise<[ + protos.google.cloud.discoveryengine.v1.ISchema[], + protos.google.cloud.discoveryengine.v1.IListSchemasRequest|null, + protos.google.cloud.discoveryengine.v1.IListSchemasResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listSchemas(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {number} request.pageSize + * The maximum number of {@link google.cloud.discoveryengine.v1.Schema|Schema}s to + * return. The service may return fewer than this value. + * + * If unspecified, at most 100 + * {@link google.cloud.discoveryengine.v1.Schema|Schema}s will be returned. + * + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} + * must match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1.Schema | Schema} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSchemasAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listSchemasStream( + request?: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listSchemas']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSchemas.createStream( + this.innerApiCalls.listSchemas as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listSchemas`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {number} request.pageSize + * The maximum number of {@link google.cloud.discoveryengine.v1.Schema|Schema}s to + * return. The service may return fewer than this value. + * + * If unspecified, at most 100 + * {@link google.cloud.discoveryengine.v1.Schema|Schema}s will be returned. + * + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} + * must match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.discoveryengine.v1.Schema | Schema}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/schema_service.list_schemas.js + * region_tag:discoveryengine_v1_generated_SchemaService_ListSchemas_async + */ + listSchemasAsync( + request?: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listSchemas']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSchemas.asyncIterate( + this.innerApiCalls['listSchemas'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationDataStorePath(project:string,location:string,dataStore:string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.schemaServiceStub && !this._terminated) { + return this.schemaServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client_config.json new file mode 100644 index 00000000000..3f6973aed28 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client_config.json @@ -0,0 +1,63 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1.SchemaService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "GetSchema": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListSchemas": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "CreateSchema": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateSchema": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "DeleteSchema": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_proto_list.json new file mode 100644 index 00000000000..60d54073cfa --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_proto_list.json @@ -0,0 +1,13 @@ +[ + "../../protos/google/cloud/discoveryengine/v1/common.proto", + "../../protos/google/cloud/discoveryengine/v1/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1/document.proto", + "../../protos/google/cloud/discoveryengine/v1/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1/schema.proto", + "../../protos/google/cloud/discoveryengine/v1/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client.ts new file mode 100644 index 00000000000..c4b9d426e03 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client.ts @@ -0,0 +1,1367 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for search. + * @class + * @memberof v1 + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SearchServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}' + ), + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationCollectionDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}' + ), + projectLocationDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + search: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1.SearchService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1.SearchService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1.SearchService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const searchServiceStubMethods = + ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + + /** + * Performs a search. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The resource name of the Search serving config, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + * @param {string} request.query + * Raw search query. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 100. Values above 100 will be coerced to 100. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {string} request.pageToken + * A page token received from a previous + * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.discoveryengine.v1.Document|Document}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.discoveryengine.v1.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {google.cloud.discoveryengine.v1.UserInfo} request.userInfo + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + * @param {number[]} request.params + * Additional search parameters. + * + * For public website search only, supported values are: + * + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + * @param {google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + * @param {google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.userPseudoId + * 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. + * + * This field should NOT have a fixed value such as `unknown_visitor`. + * + * This should be the same identifier as + * {@link google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} + * and + * {@link google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @param {google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec} request.contentSearchSpec + * The content search spec that configs the desired behavior of content + * search. + * @param {boolean} request.safeSearch + * Whether to turn on safe search. This is only supported for + * {@link |ContentConfig.PUBLIC_WEBSITE}. + * @param {number[]} request.userLabels + * The user 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. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link google.cloud.discoveryengine.v1.SearchResponse.SearchResult | SearchResult}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.discoveryengine.v1.ISearchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult[], + protos.google.cloud.discoveryengine.v1.ISearchRequest|null, + protos.google.cloud.discoveryengine.v1.ISearchResponse + ]>; + search( + request: protos.google.cloud.discoveryengine.v1.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1.ISearchRequest, + protos.google.cloud.discoveryengine.v1.ISearchResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult>): void; + search( + request: protos.google.cloud.discoveryengine.v1.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1.ISearchRequest, + protos.google.cloud.discoveryengine.v1.ISearchResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult>): void; + search( + request?: protos.google.cloud.discoveryengine.v1.ISearchRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.discoveryengine.v1.ISearchRequest, + protos.google.cloud.discoveryengine.v1.ISearchResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult>, + callback?: PaginationCallback< + protos.google.cloud.discoveryengine.v1.ISearchRequest, + protos.google.cloud.discoveryengine.v1.ISearchResponse|null|undefined, + protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult>): + Promise<[ + protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult[], + protos.google.cloud.discoveryengine.v1.ISearchRequest|null, + protos.google.cloud.discoveryengine.v1.ISearchResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'serving_config': request.servingConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The resource name of the Search serving config, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + * @param {string} request.query + * Raw search query. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 100. Values above 100 will be coerced to 100. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {string} request.pageToken + * A page token received from a previous + * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.discoveryengine.v1.Document|Document}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.discoveryengine.v1.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {google.cloud.discoveryengine.v1.UserInfo} request.userInfo + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + * @param {number[]} request.params + * Additional search parameters. + * + * For public website search only, supported values are: + * + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + * @param {google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + * @param {google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.userPseudoId + * 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. + * + * This field should NOT have a fixed value such as `unknown_visitor`. + * + * This should be the same identifier as + * {@link google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} + * and + * {@link google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @param {google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec} request.contentSearchSpec + * The content search spec that configs the desired behavior of content + * search. + * @param {boolean} request.safeSearch + * Whether to turn on safe search. This is only supported for + * {@link |ContentConfig.PUBLIC_WEBSITE}. + * @param {number[]} request.userLabels + * The user 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. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1.SearchResponse.SearchResult | SearchResult} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.discoveryengine.v1.ISearchRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'serving_config': request.servingConfig ?? '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `search`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The resource name of the Search serving config, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + * @param {string} request.query + * Raw search query. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 100. Values above 100 will be coerced to 100. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {string} request.pageToken + * A page token received from a previous + * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.discoveryengine.v1.Document|Document}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.discoveryengine.v1.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {google.cloud.discoveryengine.v1.UserInfo} request.userInfo + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + * @param {number[]} request.params + * Additional search parameters. + * + * For public website search only, supported values are: + * + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + * @param {google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + * @param {google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.userPseudoId + * 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. + * + * This field should NOT have a fixed value such as `unknown_visitor`. + * + * This should be the same identifier as + * {@link google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} + * and + * {@link google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @param {google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec} request.contentSearchSpec + * The content search spec that configs the desired behavior of content + * search. + * @param {boolean} request.safeSearch + * Whether to turn on safe search. This is only supported for + * {@link |ContentConfig.PUBLIC_WEBSITE}. + * @param {number[]} request.userLabels + * The user 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. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.discoveryengine.v1.SearchResponse.SearchResult | SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/search_service.search.js + * region_tag:discoveryengine_v1_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.discoveryengine.v1.ISearchRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'serving_config': request.servingConfig ?? '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchPath(project:string,location:string,collection:string,dataStore:string,branch:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).branch; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreServingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} serving_config + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreServingConfigPath(project:string,location:string,collection:string,dataStore:string,servingConfig:string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).data_store; + } + + /** + * Parse the serving_config from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).serving_config; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchPath(project:string,location:string,dataStore:string,branch:string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).branch; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStoreServingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} serving_config + * @returns {string} Resource name string. + */ + projectLocationDataStoreServingConfigPath(project:string,location:string,dataStore:string,servingConfig:string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).data_store; + } + + /** + * Parse the serving_config from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client_config.json new file mode 100644 index 00000000000..a923eb634aa --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client_config.json @@ -0,0 +1,43 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1.SearchService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "unavailable", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_proto_list.json new file mode 100644 index 00000000000..60d54073cfa --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_proto_list.json @@ -0,0 +1,13 @@ +[ + "../../protos/google/cloud/discoveryengine/v1/common.proto", + "../../protos/google/cloud/discoveryengine/v1/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1/document.proto", + "../../protos/google/cloud/discoveryengine/v1/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1/schema.proto", + "../../protos/google/cloud/discoveryengine/v1/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client.ts new file mode 100644 index 00000000000..c025349428b --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client.ts @@ -0,0 +1,1220 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on a website to Discovery Engine API. + * @class + * @memberof v1 + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new UserEventServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' + ), + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*}/operations',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*}/operations',},{get: '/v1/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.ImportUserEventsResponse') as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1.ImportUserEventsMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1.UserEventService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1.UserEventService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1.UserEventService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const userEventServiceStubMethods = + ['writeUserEvent', 'collectUserEvent', 'importUserEvents']; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {google.cloud.discoveryengine.v1.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.UserEvent | UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/user_event_service.write_user_event.js + * region_tag:discoveryengine_v1_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1.IUserEvent, + protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|undefined, {}|undefined + ]>; + writeUserEvent( + request: protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1.IUserEvent, + protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request: protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1.IUserEvent, + protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request?: protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1.IUserEvent, + protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1.IUserEvent, + protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1.IUserEvent, + protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } +/** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Discovery Engine API JavaScript pixel and + * Google Tag Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * 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. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.api.HttpBody | HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/user_event_service.collect_user_event.js + * region_tag:discoveryengine_v1_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|undefined, {}|undefined + ]>; + collectUserEvent( + request: protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request: protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request?: protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + +/** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.discoveryengine.v1.ImportUserEventsRequest.InlineSource} request.inlineSource + * Required. The Inline source for the input content for UserEvents. + * @param {google.cloud.discoveryengine.v1.GcsSource} request.gcsSource + * Required. Cloud Storage location for the input content. + * @param {google.cloud.discoveryengine.v1.BigQuerySource} request.bigquerySource + * Required. BigQuery input source. + * @param {string} request.parent + * Required. Parent DataStore resource name, of the form + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * @param {google.cloud.discoveryengine.v1.ImportErrorConfig} request.errorConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/user_event_service.import_user_events.js + * region_tag:discoveryengine_v1_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.discoveryengine.v1.IImportUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importUserEvents( + request: protos.google.cloud.discoveryengine.v1.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request: protos.google.cloud.discoveryengine.v1.IImportUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request?: protos.google.cloud.discoveryengine.v1.IImportUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/user_event_service.import_user_events.js + * region_tag:discoveryengine_v1_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importUserEvents, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationDataStorePath(project:string,location:string,dataStore:string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client_config.json new file mode 100644 index 00000000000..4592e12161a --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client_config.json @@ -0,0 +1,62 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1.UserEventService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "CollectUserEvent": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ImportUserEvents": { + "timeout_millis": 300000, + "retry_codes_name": "unavailable", + "retry_params_name": "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_proto_list.json new file mode 100644 index 00000000000..60d54073cfa --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_proto_list.json @@ -0,0 +1,13 @@ +[ + "../../protos/google/cloud/discoveryengine/v1/common.proto", + "../../protos/google/cloud/discoveryengine/v1/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1/document.proto", + "../../protos/google/cloud/discoveryengine/v1/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1/schema.proto", + "../../protos/google/cloud/discoveryengine/v1/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..fa16af05106 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,31 @@ +// Copyright 2023 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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const discoveryengine = require('@google-cloud/discoveryengine'); + +function main() { + const completionServiceClient = new discoveryengine.CompletionServiceClient(); + const documentServiceClient = new discoveryengine.DocumentServiceClient(); + const schemaServiceClient = new discoveryengine.SchemaServiceClient(); + const searchServiceClient = new discoveryengine.SearchServiceClient(); + const userEventServiceClient = new discoveryengine.UserEventServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..01e942f0968 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,56 @@ +// Copyright 2023 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. ** + +import {CompletionServiceClient, DocumentServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient} from '@google-cloud/discoveryengine'; + +// check that the client class type name can be used +function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { + client.close(); +} +function doStuffWithDocumentServiceClient(client: DocumentServiceClient) { + client.close(); +} +function doStuffWithSchemaServiceClient(client: SchemaServiceClient) { + client.close(); +} +function doStuffWithSearchServiceClient(client: SearchServiceClient) { + client.close(); +} +function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const completionServiceClient = new CompletionServiceClient(); + doStuffWithCompletionServiceClient(completionServiceClient); + // check that the client instance can be created + const documentServiceClient = new DocumentServiceClient(); + doStuffWithDocumentServiceClient(documentServiceClient); + // check that the client instance can be created + const schemaServiceClient = new SchemaServiceClient(); + doStuffWithSchemaServiceClient(schemaServiceClient); + // check that the client instance can be created + const searchServiceClient = new SearchServiceClient(); + doStuffWithSearchServiceClient(searchServiceClient); + // check that the client instance can be created + const userEventServiceClient = new UserEventServiceClient(); + doStuffWithUserEventServiceClient(userEventServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/install.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 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. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_completion_service_v1.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_completion_service_v1.ts new file mode 100644 index 00000000000..05a807b7923 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_completion_service_v1.ts @@ -0,0 +1,609 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as completionserviceModule from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1.CompletionServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = completionserviceModule.v1.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = completionserviceModule.v1.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v1.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new completionserviceModule.v1.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new completionserviceModule.v1.CompletionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CompleteQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CompleteQueryRequest', ['dataStore']); + request.dataStore = defaultValue1; + const expectedHeaderRequestParams = `data_store=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CompleteQueryResponse() + ); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CompleteQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CompleteQueryRequest', ['dataStore']); + request.dataStore = defaultValue1; + const expectedHeaderRequestParams = `data_store=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CompleteQueryResponse() + ); + client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery with error', async () => { + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CompleteQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CompleteQueryRequest', ['dataStore']); + request.dataStore = defaultValue1; + const expectedHeaderRequestParams = `data_store=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CompleteQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CompleteQueryRequest', ['dataStore']); + request.dataStore = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStore', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + }; + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStorePath', () => { + const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStore', () => { + const fakePath = "/rendered/path/projectLocationDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + }; + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStorePath', () => { + const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreName', () => { + const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreName', () => { + const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new completionserviceModule.v1.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_document_service_v1.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_document_service_v1.ts new file mode 100644 index 00000000000..c1dfc6418c4 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_document_service_v1.ts @@ -0,0 +1,1824 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as documentserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DocumentServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = documentserviceModule.v1.DocumentServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = documentserviceModule.v1.DocumentServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = documentserviceModule.v1.DocumentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new documentserviceModule.v1.DocumentServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentServiceStub, undefined); + await client.initialize(); + assert(client.documentServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.documentServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getDocument', () => { + it('invokes getDocument without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocument without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDocument( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocument with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocument with closed client', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDocument(request), expectedError); + }); + }); + + describe('createDocument', () => { + it('invokes createDocument without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocument without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDocument( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocument with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocument with closed client', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDocument(request), expectedError); + }); + }); + + describe('updateDocument', () => { + it('invokes updateDocument without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.UpdateDocumentRequest() + ); + request.document ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocument without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.UpdateDocumentRequest() + ); + request.document ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDocument( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocument with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.UpdateDocumentRequest() + ); + request.document ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocument with closed client', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.UpdateDocumentRequest() + ); + request.document ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDocument(request), expectedError); + }); + }); + + describe('deleteDocument', () => { + it('invokes deleteDocument without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocument without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDocument( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocument with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocument with closed client', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDocument(request), expectedError); + }); + }); + + describe('importDocuments', () => { + it('invokes importDocuments without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ImportDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importDocuments = stubLongRunningCall(expectedResponse); + const [operation] = await client.importDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importDocuments without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ImportDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importDocuments = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importDocuments( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importDocuments with call error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ImportDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importDocuments with LRO error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ImportDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportDocumentsProgress without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportDocumentsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportDocumentsProgress with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportDocumentsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('purgeDocuments', () => { + it('invokes purgeDocuments without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.PurgeDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.PurgeDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeDocuments = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeDocuments without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.PurgeDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.PurgeDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeDocuments = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeDocuments( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeDocuments with call error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.PurgeDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.PurgeDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeDocuments with LRO error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.PurgeDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.PurgeDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeDocumentsProgress without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeDocumentsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeDocumentsProgress with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeDocumentsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listDocuments', () => { + it('invokes listDocuments without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCall(expectedResponse); + const [response] = await client.listDocuments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDocuments without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDocuments( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.IDocument[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDocuments with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDocumentsStream without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + ]; + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1.Document[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1.Document) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); + assert( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listDocumentsStream with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1.Document[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1.Document) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); + assert( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDocuments without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), + ]; + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.discoveryengine.v1.IDocument[] = []; + const iterable = client.listDocumentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDocuments with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDocumentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.discoveryengine.v1.IDocument[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStoreBranch', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchPath', () => { + const result = client.projectLocationCollectionDataStoreBranchPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranch', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchPath', () => { + const result = client.projectLocationDataStoreBranchPath("projectValue", "locationValue", "dataStoreValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_schema_service_v1.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_schema_service_v1.ts new file mode 100644 index 00000000000..2c7d818420c --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_schema_service_v1.ts @@ -0,0 +1,1638 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as schemaserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.SchemaServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = schemaserviceModule.v1.SchemaServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = schemaserviceModule.v1.SchemaServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = schemaserviceModule.v1.SchemaServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new schemaserviceModule.v1.SchemaServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.schemaServiceStub, undefined); + await client.initialize(); + assert(client.schemaServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.schemaServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.schemaServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getSchema', () => { + it('invokes getSchema without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.GetSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.Schema() + ); + client.innerApiCalls.getSchema = stubSimpleCall(expectedResponse); + const [response] = await client.getSchema(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSchema without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.GetSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.Schema() + ); + client.innerApiCalls.getSchema = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSchema( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.ISchema|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSchema with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.GetSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSchema = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSchema with closed client', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.GetSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getSchema(request), expectedError); + }); + }); + + describe('createSchema', () => { + it('invokes createSchema without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CreateSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createSchema = stubLongRunningCall(expectedResponse); + const [operation] = await client.createSchema(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSchema without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CreateSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createSchema = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSchema( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSchema with call error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CreateSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSchema = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSchema with LRO error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CreateSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSchema = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createSchema(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateSchemaProgress without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateSchemaProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateSchemaProgress with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateSchemaProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateSchema', () => { + it('invokes updateSchema without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.UpdateSchemaRequest() + ); + request.schema ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateSchemaRequest', ['schema', 'name']); + request.schema.name = defaultValue1; + const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateSchema = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateSchema(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSchema without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.UpdateSchemaRequest() + ); + request.schema ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateSchemaRequest', ['schema', 'name']); + request.schema.name = defaultValue1; + const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateSchema = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSchema( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSchema with call error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.UpdateSchemaRequest() + ); + request.schema ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateSchemaRequest', ['schema', 'name']); + request.schema.name = defaultValue1; + const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSchema = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSchema with LRO error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.UpdateSchemaRequest() + ); + request.schema ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateSchemaRequest', ['schema', 'name']); + request.schema.name = defaultValue1; + const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSchema = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateSchema(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateSchemaProgress without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateSchemaProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateSchemaProgress with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateSchemaProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteSchema', () => { + it('invokes deleteSchema without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.DeleteSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteSchema = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteSchema(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchema without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.DeleteSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteSchema = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSchema( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchema with call error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.DeleteSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSchema = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchema with LRO error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.DeleteSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSchema = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteSchema(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteSchemaProgress without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteSchemaProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteSchemaProgress with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteSchemaProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listSchemas', () => { + it('invokes listSchemas without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + ]; + client.innerApiCalls.listSchemas = stubSimpleCall(expectedResponse); + const [response] = await client.listSchemas(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchemas without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + ]; + client.innerApiCalls.listSchemas = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSchemas( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.ISchema[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchemas with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSchemas = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listSchemas(request), expectedError); + const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchemasStream without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + ]; + client.descriptors.page.listSchemas.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listSchemasStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1.Schema[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1.Schema) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listSchemas.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSchemas, request)); + assert( + (client.descriptors.page.listSchemas.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listSchemasStream with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSchemas.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listSchemasStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1.Schema[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1.Schema) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listSchemas.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSchemas, request)); + assert( + (client.descriptors.page.listSchemas.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSchemas without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), + ]; + client.descriptors.page.listSchemas.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.discoveryengine.v1.ISchema[] = []; + const iterable = client.listSchemasAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSchemas with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSchemas.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSchemasAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.discoveryengine.v1.ISchema[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStore', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStorePath', () => { + const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStore', () => { + const fakePath = "/rendered/path/projectLocationDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStorePath', () => { + const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreName', () => { + const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreName', () => { + const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new schemaserviceModule.v1.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_search_service_v1.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_search_service_v1.ts new file mode 100644 index 00000000000..e7dd3e7b80a --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_search_service_v1.ts @@ -0,0 +1,925 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.SearchServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = searchserviceModule.v1.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = searchserviceModule.v1.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v1.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v1.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v1.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult[] = []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStoreBranch', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + }; + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchPath', () => { + const result = client.projectLocationCollectionDataStoreBranchPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreServingConfig', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreServingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + serving_config: "servingConfigValue", + }; + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreServingConfigPath', () => { + const result = client.projectLocationCollectionDataStoreServingConfigPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranch', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + }; + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchPath', () => { + const result = client.projectLocationDataStoreBranchPath("projectValue", "locationValue", "dataStoreValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreServingConfig', () => { + const fakePath = "/rendered/path/projectLocationDataStoreServingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + serving_config: "servingConfigValue", + }; + const client = new searchserviceModule.v1.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreServingConfigPath', () => { + const result = client.projectLocationDataStoreServingConfigPath("projectValue", "locationValue", "dataStoreValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchProjectFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchLocationFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchServingConfigFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_user_event_service_v1.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_user_event_service_v1.ts new file mode 100644 index 00000000000..a192a7eea14 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_user_event_service_v1.ts @@ -0,0 +1,1162 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as usereventserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.UserEventServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = usereventserviceModule.v1.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = usereventserviceModule.v1.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v1.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new usereventserviceModule.v1.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.WriteUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.UserEvent() + ); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.WriteUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.UserEvent() + ); + client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.IUserEvent|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.WriteUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.WriteUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CollectUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CollectUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CollectUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.CollectUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ImportUserEventsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ImportUserEventsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ImportUserEventsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1.ImportUserEventsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStore', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + }; + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStorePath', () => { + const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStore', () => { + const fakePath = "/rendered/path/projectLocationDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + }; + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStorePath', () => { + const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreName', () => { + const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreName', () => { + const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new usereventserviceModule.v1.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/tsconfig.json b/owl-bot-staging/google-cloud-discoveryengine/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/webpack.config.js b/owl-bot-staging/google-cloud-discoveryengine/v1/webpack.config.js new file mode 100644 index 00000000000..eb56fa1d866 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'CompletionService', + filename: './completion-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintignore b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintrc.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.gitignore b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.gitignore @@ -0,0 +1,14 @@ +**/*.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__ diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.jsdoc.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.jsdoc.js new file mode 100644 index 00000000000..69c2c79afc4 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 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 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/discoveryengine', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.mocharc.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 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. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +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 diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.prettierrc.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 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. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/README.md b/owl-bot-staging/google-cloud-discoveryengine/v1beta/README.md new file mode 100644 index 00000000000..3f2b1b5b595 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/README.md @@ -0,0 +1 @@ +Discoveryengine: Nodejs Client diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/linkinator.config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/package.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/package.json new file mode 100644 index 00000000000..96ea5f6882d --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/package.json @@ -0,0 +1,69 @@ +{ + "name": "@google-cloud/discoveryengine", + "version": "0.1.0", + "description": "Discoveryengine client for Node.js", + "repository": "googleapis/nodejs-discoveryengine", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google discoveryengine", + "discoveryengine", + "completion service", + "document service", + "recommendation service", + "schema service", + "search service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/common.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/common.proto new file mode 100644 index 00000000000..36a799a9b06 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/common.proto @@ -0,0 +1,129 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; +option (google.api.resource_definition) = { + type: "discoveryengine.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}" + pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}" +}; +option (google.api.resource_definition) = { + type: "discoveryengine.googleapis.com/DataStore" + pattern: "projects/{project}/locations/{location}/dataStores/{data_store}" + pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}" +}; +option (google.api.resource_definition) = { + type: "discoveryengine.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}" + pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}" +}; + +// A floating point interval. +message Interval { + // The lower bound of the interval. If neither of the min fields are + // set, then the lower bound is negative infinity. + // + // This field must be not larger than max. + // Otherwise, an `INVALID_ARGUMENT` error is returned. + oneof min { + // Inclusive lower bound. + double minimum = 1; + + // Exclusive lower bound. + double exclusive_minimum = 2; + } + + // The upper bound of the interval. If neither of the max fields are + // set, then the upper bound is positive infinity. + // + // This field must be not smaller than min. + // Otherwise, an `INVALID_ARGUMENT` error is returned. + oneof max { + // Inclusive upper bound. + double maximum = 3; + + // Exclusive upper bound. + double exclusive_maximum = 4; + } +} + +// A custom attribute that is not explicitly modeled in a resource, e.g. +// [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is + // returned. + // + // Exactly one of + // [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] + // or + // [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] + // should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of + // [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] + // or + // [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] + // should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. + repeated double numbers = 2; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. Don't set for anonymous users. + // + // Always use a hashed value for this ID. + // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded + // model quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + string user_id = 1; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent] + // or if + // [UserEvent.direct_user_request][google.cloud.discoveryengine.v1beta.UserEvent.direct_user_request] + // is set. + string user_agent = 2; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/completion_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/completion_service.proto new file mode 100644 index 00000000000..cd003bd1fa2 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/completion_service.proto @@ -0,0 +1,118 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// Service for Auto-Completion. +service CompletionService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified user input with keyword suggestions. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v1beta/{data_store=projects/*/locations/*/dataStores/*}:completeQuery" + additional_bindings { + get: "/v1beta/{data_store=projects/*/locations/*/collections/*/dataStores/*}:completeQuery" + } + }; + } +} + +// Request message for +// [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery] +// method. +message CompleteQueryRequest { + // Required. The parent data store resource name for which the completion is + // performed, such as + // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`. + string data_store = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // Required. The typeahead input used to fetch suggestions. Maximum length is + // 128 characters. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Selects data model of query suggestions for serving. Currently supported + // values: + // + // * `document` - Using suggestions generated from user-imported documents. + // * `search-history` - Using suggestions generated from the past history of + // [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + // API calls. Do not use it when there is no traffic for Search API. + // * `user-event` - Using suggestions generated from user-imported search + // events. + // * `document-completable` - Using suggestions taken directly from + // user-imported document fields marked as completable. + // + // Default values: + // + // * `document` is the default model for regular dataStores. + // * `search-history` is the default model for + // [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH] + // dataStores. + string query_model = 3; + + // 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. + // + // This field should NOT have a fixed value such as `unknown_visitor`. + // + // This should be the same identifier as + // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + // and + // [SearchRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.SearchRequest.user_pseudo_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + string user_pseudo_id = 4; +} + +// Response message for +// [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery] +// method. +message CompleteQueryResponse { + // Suggestions as search queries. + message QuerySuggestion { + // The suggestion for the query. + string suggestion = 1; + } + + // Results of the matched query suggestions. The result list is ordered and + // the first result is a top suggestion. + repeated QuerySuggestion query_suggestions = 1; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document.proto new file mode 100644 index 00000000000..677228d9011 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document.proto @@ -0,0 +1,123 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// Document captures all raw metadata information of items to be recommended or +// searched. +message Document { + option (google.api.resource) = { + type: "discoveryengine.googleapis.com/Document" + pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}" + pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}" + }; + + // Unstructured data linked to this document. + message Content { + oneof content { + // The content represented as a stream of bytes. The maximum length is + // 1,000,000 bytes (1 MB / ~0.95 MiB). + // + // Note: As with all `bytes` fields, this field is represented as pure + // binary in Protocol Buffers and base64-encoded string in JSON. For + // example, `abc123!?$*&()'-=@~` should be represented as + // `YWJjMTIzIT8kKiYoKSctPUB+` in JSON. See + // https://developers.google.com/protocol-buffers/docs/proto3#json. + bytes raw_bytes = 2; + + // The URI of the content. Only Cloud Storage URIs (e.g. + // `gs://bucket-name/path/to/file`) are supported. The maximum file size + // is 100 MB. + string uri = 3; + } + + // The MIME type of the content. Supported types: + // + // * `application/pdf` (PDF, only native PDFs are supported for now) + // * `text/html` (HTML) + // * `application/vnd.openxmlformats-officedocument.wordprocessingml.document` (DOCX) + // * `application/vnd.openxmlformats-officedocument.presentationml.presentation` (PPTX) + // * `text/plain` (TXT) + // + // See https://www.iana.org/assignments/media-types/media-types.xhtml. + string mime_type = 1; + } + + // Data representation. One of + // [struct_data][google.cloud.discoveryengine.v1beta.Document.struct_data] or + // [json_data][google.cloud.discoveryengine.v1beta.Document.json_data] should + // be provided otherwise an `INVALID_ARGUMENT` error is thrown. + oneof data { + // The structured JSON data for the document. It should conform to the + // registered + // [Schema.schema][google.cloud.discoveryengine.v1beta.Schema.schema] or an + // `INVALID_ARGUMENT` error is thrown. + google.protobuf.Struct struct_data = 4; + + // The JSON string representation of the document. It should conform to the + // registered + // [Schema.schema][google.cloud.discoveryengine.v1beta.Schema.schema] or an + // `INVALID_ARGUMENT` error is thrown. + string json_data = 5; + } + + // Immutable. The full resource name of the document. + // Format: + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document_id}`. + // + // This field must be a UTF-8 encoded string with a length limit of 1024 + // characters. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The identifier of the document. + // + // Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + // standard with a length limit of 63 characters. + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // The identifier of the schema located in the same data store. + string schema_id = 3; + + // The unstructured data linked to this document. Content must be set if this + // document is under a + // `CONTENT_REQUIRED` data store. + Content content = 10; + + // The identifier of the parent document. Currently supports at most two level + // document hierarchy. + // + // Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + // standard with a length limit of 63 characters. + string parent_document_id = 7; + + // Output only. This field is OUTPUT_ONLY. + // It contains derived data that are not in the original input document. + google.protobuf.Struct derived_struct_data = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document_service.proto new file mode 100644 index 00000000000..e76d7ce56ca --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document_service.proto @@ -0,0 +1,316 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1beta/document.proto"; +import "google/cloud/discoveryengine/v1beta/import_config.proto"; +import "google/cloud/discoveryengine/v1beta/purge_config.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "DocumentServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// Service for ingesting +// [Document][google.cloud.discoveryengine.v1beta.Document] information of the +// customer's website. +service DocumentService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Gets a [Document][google.cloud.discoveryengine.v1beta.Document]. + rpc GetDocument(GetDocumentRequest) returns (Document) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" + additional_bindings { + get: "/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s. + rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents" + additional_bindings { + get: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a [Document][google.cloud.discoveryengine.v1beta.Document]. + rpc CreateDocument(CreateDocumentRequest) returns (Document) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents" + body: "document" + additional_bindings { + post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents" + body: "document" + } + }; + option (google.api.method_signature) = "parent,document,document_id"; + } + + // Updates a [Document][google.cloud.discoveryengine.v1beta.Document]. + rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { + option (google.api.http) = { + patch: "/v1beta/{document.name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" + body: "document" + additional_bindings { + patch: "/v1beta/{document.name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" + body: "document" + } + }; + } + + // Deletes a [Document][google.cloud.discoveryengine.v1beta.Document]. + rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" + additional_bindings { + delete: "/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Bulk import of multiple + // [Document][google.cloud.discoveryengine.v1beta.Document]s. Request + // processing may be synchronous. Non-existing items will be created. + // + // Note: It is possible for a subset of the + // [Document][google.cloud.discoveryengine.v1beta.Document]s to be + // successfully updated. + rpc ImportDocuments(ImportDocumentsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:import" + body: "*" + additional_bindings { + post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:import" + body: "*" + } + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.discoveryengine.v1beta.ImportDocumentsResponse" + metadata_type: "google.cloud.discoveryengine.v1beta.ImportDocumentsMetadata" + }; + } + + // Permanently deletes all selected + // [Document][google.cloud.discoveryengine.v1beta.Document]s in a branch. + // + // This process is asynchronous. Depending on the number of + // [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, + // this operation can take hours to complete. Before the delete operation + // completes, some [Document][google.cloud.discoveryengine.v1beta.Document]s + // might still be returned by + // [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument] + // or + // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments]. + // + // To get a list of the + // [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, + // set + // [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force] + // to false. + rpc PurgeDocuments(PurgeDocumentsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:purge" + body: "*" + additional_bindings { + post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:purge" + body: "*" + } + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.discoveryengine.v1beta.PurgeDocumentsResponse" + metadata_type: "google.cloud.discoveryengine.v1beta.PurgeDocumentsMetadata" + }; + } +} + +// Request message for +// [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument] +// method. +message GetDocumentRequest { + // Required. Full resource name of + // [Document][google.cloud.discoveryengine.v1beta.Document], such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + // + // If the caller does not have permission to access the + // [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + // whether or not it exists, a `PERMISSION_DENIED` error is returned. + // + // If the requested [Document][google.cloud.discoveryengine.v1beta.Document] + // does not exist, a `NOT_FOUND` error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Document" + } + ]; +} + +// Request message for +// [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] +// method. +message ListDocumentsRequest { + // Required. The parent branch resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + // Use `default_branch` as the branch ID, to list documents under the default + // branch. + // + // If the caller does not have permission to list [Documents][]s under this + // branch, regardless of whether or not this branch exists, a + // `PERMISSION_DENIED` error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Branch" + } + ]; + + // Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]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. + int32 page_size = 2; + + // A page token + // [ListDocumentsResponse.next_page_token][google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token], + // received from a previous + // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] + // must match the call that provided the page token. Otherwise, an + // `INVALID_ARGUMENT` error is returned. + string page_token = 3; +} + +// Response message for +// [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] +// method. +message ListDocumentsResponse { + // The [Document][google.cloud.discoveryengine.v1beta.Document]s. + repeated Document documents = 1; + + // A token that can be sent as + // [ListDocumentsRequest.page_token][google.cloud.discoveryengine.v1beta.ListDocumentsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request message for +// [DocumentService.CreateDocument][google.cloud.discoveryengine.v1beta.DocumentService.CreateDocument] +// method. +message CreateDocumentRequest { + // Required. The parent resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Branch" + } + ]; + + // Required. The [Document][google.cloud.discoveryengine.v1beta.Document] to + // create. + Document document = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the + // [Document][google.cloud.discoveryengine.v1beta.Document], which will become + // the final component of the + // [Document.name][google.cloud.discoveryengine.v1beta.Document.name]. + // + // If the caller does not have permission to create the + // [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + // whether or not it exists, a `PERMISSION_DENIED` error is returned. + // + // This field must be unique among all + // [Document][google.cloud.discoveryengine.v1beta.Document]s with the same + // [parent][google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent]. + // Otherwise, an `ALREADY_EXISTS` error is returned. + // + // This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + // standard with a length limit of 63 characters. Otherwise, an + // `INVALID_ARGUMENT` error is returned. + string document_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for +// [DocumentService.UpdateDocument][google.cloud.discoveryengine.v1beta.DocumentService.UpdateDocument] +// method. +message UpdateDocumentRequest { + // Required. The document to update/create. + // + // If the caller does not have permission to update the + // [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + // whether or not it exists, a `PERMISSION_DENIED` error is returned. + // + // If the [Document][google.cloud.discoveryengine.v1beta.Document] to update + // does not exist and + // [allow_missing][google.cloud.discoveryengine.v1beta.UpdateDocumentRequest.allow_missing] + // is not set, a `NOT_FOUND` error is returned. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // If set to true, and the + // [Document][google.cloud.discoveryengine.v1beta.Document] is not found, a + // new [Document][google.cloud.discoveryengine.v1beta.Document] will be + // created. + bool allow_missing = 2; +} + +// Request message for +// [DocumentService.DeleteDocument][google.cloud.discoveryengine.v1beta.DocumentService.DeleteDocument] +// method. +message DeleteDocumentRequest { + // Required. Full resource name of + // [Document][google.cloud.discoveryengine.v1beta.Document], such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + // + // If the caller does not have permission to delete the + // [Document][google.cloud.discoveryengine.v1beta.Document], regardless of + // whether or not it exists, a `PERMISSION_DENIED` error is returned. + // + // If the [Document][google.cloud.discoveryengine.v1beta.Document] to delete + // does not exist, a `NOT_FOUND` error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Document" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/import_config.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/import_config.proto new file mode 100644 index 00000000000..9c68d47a0fe --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/import_config.proto @@ -0,0 +1,342 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1beta/document.proto"; +import "google/cloud/discoveryengine/v1beta/user_event.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// Cloud Storage location for input content. +message GcsSource { + // Required. Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. + // + // A request can contain at most 100 files (or 100,000 files if `data_schema` + // is `content`). Each file can be up to 2 GB (or 100 MB if `data_schema` is + // `content`). + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for document imports: + // + // * `document` (default): One JSON + // [Document][google.cloud.discoveryengine.v1beta.Document] per line. Each + // document must + // have a valid + // [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. + // * `content`: Unstructured data (e.g. PDF, HTML). Each file matched by + // `input_uris` will become a document, with the ID set to the first 128 + // bits of SHA256(URI) encoded as a hex string. + // * `custom`: One custom data JSON per row in arbitrary format that conforms + // the defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the + // data store. This can only be used by the GENERIC Data Store vertical. + // * `csv`: A CSV file with header conforming the defined + // [Schema][google.cloud.discoveryengine.v1beta.Schema] of the + // data store. Each entry after the header will be imported as a Document. + // This can only be used by the GENERIC Data Store vertical. + // + // Supported values for user even imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + google.type.Date partition_date = 5; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 1; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 3 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 4; + + // The schema to use when parsing the data from the source. + // + // Supported values for user event imports: + // + // * `user_event` (default): One + // [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per row. + // + // Supported values for document imports: + // + // * `document` (default): One + // [Document][google.cloud.discoveryengine.v1beta.Document] format per + // row. Each document must have a valid + // [Document.id][google.cloud.discoveryengine.v1beta.Document.id] and one of + // [Document.json_data][google.cloud.discoveryengine.v1beta.Document.json_data] + // or + // [Document.struct_data][google.cloud.discoveryengine.v1beta.Document.struct_data]. + // * `custom`: One custom data per row in arbitrary format that conforms the + // defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the data + // store. This can only be used by the GENERIC Data Store vertical. + string data_schema = 6; +} + +// Configuration of destination for Import related errors. +message ImportErrorConfig { + // Required. Errors destination. + oneof destination { + // Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors will be written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // The inline source for the input config for ImportUserEvents method. + message InlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // Required - The desired input source of the user event data. + oneof source { + // The Inline source for the input content for UserEvents. + InlineSource inline_source = 2; + + // Cloud Storage location for the input content. + GcsSource gcs_source = 3; + + // BigQuery input source. + BigQuerySource bigquery_source = 4; + } + + // Required. Parent DataStore resource name, of the form + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorConfig error_config = 5; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorConfig error_config = 2; + + // Count of user events imported with complete existing Documents. + int64 joined_events_count = 3; + + // Count of user events imported, but with Document information not found + // in the existing Branch. + int64 unjoined_events_count = 4; +} + +// Metadata related to the progress of the Import operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ImportUserEventsMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; +} + +// Metadata related to the progress of the ImportDocuments operation. This will +// be returned by the google.longrunning.Operation.metadata field. +message ImportDocumentsMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; +} + +// Request message for Import methods. +message ImportDocumentsRequest { + // The inline source for the input config for ImportDocuments method. + message InlineSource { + // Required. A list of documents to update/create. Each document must have a + // valid [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. + // Recommended max of 100 items. + repeated Document documents = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // Indicates how imported documents are reconciled with the existing documents + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new documents or updates existing documents. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire document dataset. Existing + // documents may be deleted if they are not present in the source location. + FULL = 2; + } + + // Required. The source of the input. + oneof source { + // The Inline source for the input content for documents. + InlineSource inline_source = 2; + + // Cloud Storage location for the input content. + GcsSource gcs_source = 3; + + // BigQuery input source. + BigQuerySource bigquery_source = 4; + } + + // Required. The parent branch resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + // Requires create/update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Branch" + } + ]; + + // The desired location of errors incurred during the Import. + ImportErrorConfig error_config = 5; + + // The mode of reconciliation between existing documents and the documents to + // be imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 6; + + // Whether to automatically generate IDs for the documents if absent. + // + // If set to `true`, + // [Document.id][google.cloud.discoveryengine.v1beta.Document.id]s are + // automatically generated based on the hash of the payload, where IDs may not + // be consistent during multiple imports. In which case + // [ReconciliationMode.FULL][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.FULL] + // is highly recommended to avoid duplicate contents. If unset or set to + // `false`, [Document.id][google.cloud.discoveryengine.v1beta.Document.id]s + // have to be specified using + // [id_field][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.id_field], + // otherwises, documents without IDs will fail to be imported. + // + // Only set this field when using + // [GcsSource][google.cloud.discoveryengine.v1beta.GcsSource] or + // [BigQuerySource][google.cloud.discoveryengine.v1beta.BigQuerySource], and + // when + // [GcsSource.data_schema][google.cloud.discoveryengine.v1beta.GcsSource.data_schema] + // or + // [BigQuerySource.data_schema][google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema] + // is `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown. + bool auto_generate_ids = 8; + + // The field in the Cloud Storage and BigQuery sources that indicates the + // unique IDs of the documents. + // + // For [GcsSource][google.cloud.discoveryengine.v1beta.GcsSource] it is the + // key of the JSON field. For instance, `my_id` for JSON `{"my_id": + // "some_uuid"}`. For + // [BigQuerySource][google.cloud.discoveryengine.v1beta.BigQuerySource] it is + // the column name of the BigQuery table where the unique ids are stored. + // + // The values of the JSON field or the BigQuery column will be used as the + // [Document.id][google.cloud.discoveryengine.v1beta.Document.id]s. The JSON + // field or the BigQuery column must be of string type, and the values must be + // set as valid strings conform to + // [RFC-1034](https://tools.ietf.org/html/rfc1034) with 1-63 characters. + // Otherwise, documents without valid IDs will fail to be imported. + // + // Only set this field when using + // [GcsSource][google.cloud.discoveryengine.v1beta.GcsSource] or + // [BigQuerySource][google.cloud.discoveryengine.v1beta.BigQuerySource], and + // when + // [GcsSource.data_schema][google.cloud.discoveryengine.v1beta.GcsSource.data_schema] + // or + // [BigQuerySource.data_schema][google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema] + // is `custom`. And only set this field when + // [auto_generate_ids][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.auto_generate_ids] + // is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. + // + // If it is unset, a default value `_id` is used when importing from the + // allowed data sources. + string id_field = 9; +} + +// Response of the +// [ImportDocumentsRequest][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest]. +// If the long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportDocumentsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorConfig error_config = 2; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/purge_config.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/purge_config.proto new file mode 100644 index 00000000000..559bc4a021c --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/purge_config.proto @@ -0,0 +1,86 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// Request message for +// [DocumentService.PurgeDocuments][google.cloud.discoveryengine.v1beta.DocumentService.PurgeDocuments] +// method. +message PurgeDocumentsRequest { + // Required. The parent resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Branch" + } + ]; + + // Required. Filter matching documents to purge. Only currently supported + // value is + // `*` (all items). + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually performs the purge. If `force` is set to false, return the + // expected purge count without deleting any documents. + bool force = 3; +} + +// Response message for +// [DocumentService.PurgeDocuments][google.cloud.discoveryengine.v1beta.DocumentService.PurgeDocuments] +// method. If the long running operation is successfully done, then this message +// is returned by the google.longrunning.Operations.response field. +message PurgeDocumentsResponse { + // The total count of documents purged as a result of the operation. + int64 purge_count = 1; + + // A sample of document names that will be deleted. Only populated if `force` + // is set to false. A max of 100 names will be returned and the names are + // chosen at random. + repeated string purge_sample = 2 [(google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Document" + }]; +} + +// Metadata related to the progress of the PurgeDocuments operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeDocumentsMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were deleted successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto new file mode 100644 index 00000000000..85eb652f205 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto @@ -0,0 +1,206 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1beta/document.proto"; +import "google/cloud/discoveryengine/v1beta/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "RecommendationServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// Service for making recommendations. +service RecommendationService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Makes a recommendation, which requires a contextual user event. + rpc Recommend(RecommendRequest) returns (RecommendResponse) { + option (google.api.http) = { + post: "/v1beta/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:recommend" + body: "*" + additional_bindings { + post: "/v1beta/{serving_config=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:recommend" + body: "*" + } + }; + } +} + +// Request message for Recommend method. +message RecommendRequest { + // Required. Full resource name of the format: + // `projects/*/locations/global/collections/*/dataStores/*/servingConfigs/*` + // + // Before you can request recommendations from your model, you must create at + // least one serving config for it. + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/ServingConfig" + } + ]; + + // Required. Context about the user, what they are looking at and what action + // they took to trigger the Recommend 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.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + // or + // [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.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.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + // to a random unique ID and leave + // [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id] + // unset. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return. Set this property + // to the number of recommendation 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. + int32 page_size = 3; + + // Filter for restricting recommendation results with a length limit of 5,000 + // characters. Currently, only filter expressions on the `filter_tags` + // attribute is supported. + // + // + // Examples: + // + // * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))` + // * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))` + // + // If your filter blocks all results, the API will return generic + // (unfiltered) popular Documents. If you only want results strictly matching + // the filters, set `strictFiltering` to True in + // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params] + // to receive empty results instead. + // + // Note that the API will never return + // [Document][google.cloud.discoveryengine.v1beta.Document]s with + // `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices. + string filter = 4; + + // Use validate only mode for this recommendation query. If set to true, a + // fake model will be used that returns arbitrary Document IDs. + // Note that the validate only mode should only be used for testing the API, + // or if the model is not ready. + bool validate_only = 5; + + // Additional domain specific parameters for the recommendations. + // + // Allowed values: + // + // * `returnDocument`: Boolean. If set to true, the associated Document + // object will be returned in + // [RecommendResponse.RecommendationResult.document][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document]. + // * `returnScore`: Boolean. If set to true, the recommendation 'score' + // corresponding to each returned Document will be set in + // [RecommendResponse.RecommendationResult.metadata][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata]. + // The given 'score' indicates the probability of a Document conversion + // given the user's context and history. + // * `strictFiltering`: Boolean. True by default. If set to false, the service + // will return generic (unfiltered) popular Documents instead of empty if + // your filter blocks all recommendation results. + // * `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 recommendation results + // based on Document category. + map params = 6; + + // The user 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 [Requirements for + // labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map user_labels = 8; +} + +// Response message for Recommend method. +message RecommendResponse { + // RecommendationResult represents a generic recommendation result with + // associated metadata. + message RecommendationResult { + // Resource ID of the recommended Document. + string id = 1; + + // Set if `returnDocument` is set to true in + // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. + Document document = 2; + + // Additional Document metadata / annotations. + // + // Possible values: + // + // * `score`: Recommendation score in double value. Is set if + // `returnScore` is set to true in + // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. + map metadata = 3; + } + + // A list of recommended Documents. The order represents the ranking (from the + // most relevant Document to the least). + repeated RecommendationResult results = 1; + + // A unique attribution token. This should be included in the + // [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting + // from this recommendation, which enables accurate attribution of + // recommendation model performance. + string attribution_token = 2; + + // IDs of documents in the request that were missing from the default Branch + // associated with the requested ServingConfig. + repeated string missing_ids = 3; + + // True if + // [RecommendRequest.validate_only][google.cloud.discoveryengine.v1beta.RecommendRequest.validate_only] + // was set. + bool validate_only = 4; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema.proto new file mode 100644 index 00000000000..ffc58799108 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema.proto @@ -0,0 +1,58 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "SchemaProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// Defines the structure and layout of a type of document data. +message Schema { + option (google.api.resource) = { + type: "discoveryengine.googleapis.com/Schema" + pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}" + pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}" + }; + + // Schema representation. One of + // [struct_schema][google.cloud.discoveryengine.v1beta.Schema.struct_schema] + // or [json_schema][google.cloud.discoveryengine.v1beta.Schema.json_schema] + // should be provided otherwise an INVALID_ARGUMENT error is thrown. + oneof schema { + // The structured representation of the schema. + google.protobuf.Struct struct_schema = 2; + + // The JSON representation of the schema. + string json_schema = 3; + } + + // Immutable. The full resource name of the schema, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + // + // This field must be a UTF-8 encoded string with a length limit of 1024 + // characters. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema_service.proto new file mode 100644 index 00000000000..bad4b913927 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema_service.proto @@ -0,0 +1,259 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1beta/schema.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "SchemaServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// Service for managing [Schema][google.cloud.discoveryengine.v1beta.Schema]s. +service SchemaService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Gets a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + rpc GetSchema(GetSchemaRequest) returns (Schema) { + option (google.api.http) = { + get: "/v1beta/{name=projects/*/locations/*/dataStores/*/schemas/*}" + additional_bindings { + get: "/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Schema][google.cloud.discoveryengine.v1beta.Schema]s. + rpc ListSchemas(ListSchemasRequest) returns (ListSchemasResponse) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/locations/*/dataStores/*}/schemas" + additional_bindings { + get: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/schemas" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + rpc CreateSchema(CreateSchemaRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*/locations/*/dataStores/*}/schemas" + body: "schema" + additional_bindings { + post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/schemas" + body: "schema" + } + }; + option (google.api.method_signature) = "parent,schema,schema_id"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.discoveryengine.v1beta.Schema" + metadata_type: "google.cloud.discoveryengine.v1beta.CreateSchemaMetadata" + }; + } + + // Updates a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + rpc UpdateSchema(UpdateSchemaRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1beta/{schema.name=projects/*/locations/*/dataStores/*/schemas/*}" + body: "schema" + additional_bindings { + patch: "/v1beta/{schema.name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" + body: "schema" + } + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.discoveryengine.v1beta.Schema" + metadata_type: "google.cloud.discoveryengine.v1beta.UpdateSchemaMetadata" + }; + } + + // Deletes a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + rpc DeleteSchema(DeleteSchemaRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1beta/{name=projects/*/locations/*/dataStores/*/schemas/*}" + additional_bindings { + delete: "/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "google.cloud.discoveryengine.v1beta.DeleteSchemaMetadata" + }; + } +} + +// Request message for +// [SchemaService.GetSchema][google.cloud.discoveryengine.v1beta.SchemaService.GetSchema] +// method. +message GetSchemaRequest { + // Required. The full resource name of the schema, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Schema" + } + ]; +} + +// Request message for +// [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] +// method. +message ListSchemasRequest { + // Required. The parent data store resource name, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // The maximum number of [Schema][google.cloud.discoveryengine.v1beta.Schema]s + // to return. The service may return fewer than this value. + // + // If unspecified, at most 100 + // [Schema][google.cloud.discoveryengine.v1beta.Schema]s will be returned. + // + // The maximum value is 1000; values above 1000 will be coerced to 1000. + int32 page_size = 2; + + // A page token, received from a previous + // [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] + // must match the call that provided the page token. + string page_token = 3; +} + +// Response message for +// [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] +// method. +message ListSchemasResponse { + // The [Schema][google.cloud.discoveryengine.v1beta.Schema]s. + repeated Schema schemas = 1; + + // A token that can be sent as + // [ListSchemasRequest.page_token][google.cloud.discoveryengine.v1beta.ListSchemasRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request message for +// [SchemaService.CreateSchema][google.cloud.discoveryengine.v1beta.SchemaService.CreateSchema] +// method. +message CreateSchemaRequest { + // Required. The parent data store resource name, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to + // create. + Schema schema = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the + // [Schema][google.cloud.discoveryengine.v1beta.Schema], which will become the + // final component of the + // [Schema.name][google.cloud.discoveryengine.v1beta.Schema.name]. + // + // This field should conform to + // [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length + // limit of 63 characters. + string schema_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for +// [SchemaService.UpdateSchema][google.cloud.discoveryengine.v1beta.SchemaService.UpdateSchema] +// method. +message UpdateSchemaRequest { + // Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to + // update. + Schema schema = 1 [(google.api.field_behavior) = REQUIRED]; + + // If set to true, and the + // [Schema][google.cloud.discoveryengine.v1beta.Schema] is not found, a new + // [Schema][google.cloud.discoveryengine.v1beta.Schema] will be created. In + // this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for +// [SchemaService.DeleteSchema][google.cloud.discoveryengine.v1beta.SchemaService.DeleteSchema] +// method. +message DeleteSchemaRequest { + // Required. The full resource name of the schema, in the format of + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Schema" + } + ]; +} + +// Metadata for Create Schema LRO. +message CreateSchemaMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} + +// Metadata for UpdateSchema LRO. +message UpdateSchemaMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} + +// Metadata for DeleteSchema LRO. +message DeleteSchemaMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/search_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/search_service.proto new file mode 100644 index 00000000000..21c48e0734d --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/search_service.proto @@ -0,0 +1,617 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1beta/common.proto"; +import "google/cloud/discoveryengine/v1beta/document.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// Service for search. +service SearchService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v1beta/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:search" + body: "*" + additional_bindings { + post: "/v1beta/{serving_config=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:search" + body: "*" + } + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] +// method. +message SearchRequest { + // A facet specification to perform faceted search. + message FacetSpec { + // Specifies how a facet is computed. + message FacetKey { + // Required. Supported textual and numerical facet keys in + // [Document][google.cloud.discoveryengine.v1beta.Document] object, over + // which the facet values are computed. Facet key is case-sensitive. + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Set only if values should be bucketized into intervals. Must be set + // for facets with numerical values. Must not be set for facet with text + // values. Maximum number of intervals is 30. + repeated Interval intervals = 2; + + // Only get facet for the given restricted values. Only supported on + // textual fields. For example, suppose "category" has three values + // "Action > 2022", "Action > 2021" and "Sci-Fi > 2022". If set + // "restricted_values" to "Action > 2022", the "category" facet will only + // contain "Action > 2022". Only supported on textual fields. Maximum + // is 10. + repeated string restricted_values = 3; + + // Only get facet values that start with the given string prefix. For + // example, suppose "category" has three values "Action > 2022", + // "Action > 2021" and "Sci-Fi > 2022". If set "prefixes" to "Action", the + // "category" facet will only contain "Action > 2022" and "Action > 2021". + // Only supported on textual fields. Maximum is 10. + repeated string prefixes = 4; + + // Only get facet values that contains the given strings. For example, + // suppose "category" has three values "Action > 2022", + // "Action > 2021" and "Sci-Fi > 2022". If set "contains" to "2022", the + // "category" facet will only contain "Action > 2022" and "Sci-Fi > 2022". + // Only supported on textual fields. Maximum is 10. + repeated string contains = 5; + + // True to make facet keys case insensitive when getting faceting + // values with prefixes or contains; false otherwise. + bool case_insensitive = 6; + + // The order in which documents are returned. + // + // Allowed values are: + // + // * "count desc", which means order by + // [SearchResponse.Facet.values.count][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.count] + // descending. + // + // * "value desc", which means order by + // [SearchResponse.Facet.values.value][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.value] + // descending. + // Only applies to textual facets. + // + // If not set, textual values are sorted in [natural + // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + // intervals are sorted in the order given by + // [FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. + string order_by = 7; + } + + // Required. The facet key specification. + FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum of facet values that should be returned for this facet. If + // unspecified, defaults to 20. The maximum allowed value is 300. Values + // above 300 will be coerced to 300. + // + // If this field is negative, an `INVALID_ARGUMENT` is returned. + int32 limit = 2; + + // List of keys to exclude when faceting. + // + // + // By default, + // [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] + // is not excluded from the filter unless it is listed in this field. + // + // Listing a facet key in this field allows its values to appear as facet + // results, even when they are filtered out of search results. Using this + // field does not affect what search results are returned. + // + // For example, suppose there are 100 documents with the color facet "Red" + // and 200 documents with the color facet "Blue". A query containing the + // filter "color:ANY("Red")" and having "color" as + // [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] + // would by default return only "Red" documents in the search results, and + // also return "Red" with count 100 as the only color facet. Although there + // are also blue documents available, "Blue" would not be shown as an + // available facet value. + // + // If "color" is listed in "excludedFilterKeys", then the query returns the + // facet values "Red" with count 100 and "Blue" with count 200, because the + // "color" key is now excluded from the filter. Because this field doesn't + // affect search results, the search results are still correctly filtered to + // return only "Red" documents. + // + // A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + // error is returned. + repeated string excluded_filter_keys = 3; + + // Enables dynamic position for this facet. If set to true, the position of + // this facet among all facets in the response is determined automatically. + // It will be ordered together with dynamic facets if dynamic + // facets is enabled. If set to false, the position of this facet in the + // response will be the same as in the request, and it will be ranked before + // the facets with dynamic position enable and all dynamic facets. + // + // For example, you may always want to have rating facet returned in + // the response, but it's not necessarily to always display the rating facet + // at the top. In that case, you can set enable_dynamic_position to true so + // that the position of rating facet in response will be determined + // automatically. + // + // Another example, assuming you have the following facets in the request: + // + // * "rating", enable_dynamic_position = true + // + // * "price", enable_dynamic_position = false + // + // * "brands", enable_dynamic_position = false + // + // And also you have a dynamic facets enable, which will generate a facet + // 'gender'. Then the final order of the facets in the response can be + // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + // "rating") depends on how API orders "gender" and "rating" facets. + // However, notice that "price" and "brands" will always be + // ranked at 1st and 2nd position since their enable_dynamic_position are + // false. + bool enable_dynamic_position = 4; + } + + // Boost specification to boost certain documents. + message BoostSpec { + // Boost applies to documents which match a condition. + message ConditionBoostSpec { + // An expression which specifies a boost condition. The syntax and + // supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost documents with document ID "doc_1" or "doc_2", and + // color + // "Red" or "Blue": + // * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue")) + string condition = 1; + + // Strength of the condition boost, which should be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the document a big promotion. However, it does not + // necessarily mean that the boosted document will be the top result at + // all times, nor that other documents will be excluded. Results could + // still be shown even when none of them matches the condition. And + // results that are significantly more relevant to the search query can + // still trump your heavily favored but irrelevant documents. + // + // Setting to -1.0 gives the document a big demotion. However, results + // that are deeply relevant might still be shown. The document will have + // an upstream battle to get a fairly high ranking, but it is not blocked + // out completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 2; + } + + // Condition boost specifications. If a document matches multiple conditions + // in the specifictions, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 20. + repeated ConditionBoostSpec condition_boost_specs = 1; + } + + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. In this case, server behavior + // defaults to + // [Condition.DISABLED][google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.discoveryengine.v1beta.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by the Search API. + AUTO = 2; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + } + + // The specification for query spell correction. + message SpellCorrectionSpec { + // Enum describing under which mode spell correction should occur. + enum Mode { + // Unspecified spell correction mode. In this case, server behavior + // defaults to + // [Mode.AUTO][google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Search API will try to find a spell suggestion if there + // is any and put in the + // [SearchResponse.corrected_query][google.cloud.discoveryengine.v1beta.SearchResponse.corrected_query]. + // The spell suggestion will not be used as the search query. + SUGGESTION_ONLY = 1; + + // Automatic spell correction built by the Search API. Search will + // be based on the corrected query if found. + AUTO = 2; + } + + // The mode under which spell correction should take effect to + // replace the original search query. Default to + // [Mode.AUTO][google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The specification that configs the desired behavior of the UCS content + // search. + message ContentSearchSpec { + // The specification that configs the snippet in the search results. + message SnippetSpec { + // Max number of snippets returned in each search result. + // + // A snippet is an infomartive summary of a content with highlighting for + // UI rendering. + // + // If the matching snippets is less than the max_snippet_count, return all + // of the snippets; otherwise, return the max_snippet_count. + // + // At most 5 snippets will be returned for each SearchResult. + int32 max_snippet_count = 1; + + // if true, only snippet reference is returned. + bool reference_only = 2; + } + + // The specification that configs the summary in the search response. + message SummarySpec { + // The number of top results the summary should be generated from. + // If the number of returned results is less than summary_result_count, + // then the summary would be derived from all the results; otherwise, the + // summary would be derived from the top results. + // + // At most 5 results can be used for generating summary. + int32 summary_result_count = 1; + } + + // The specification that configs the extractive content in search results. + message ExtractiveContentSpec { + // The max number of extractive answers returned in each search result. + // + // An extractive answer is a verbatim answer extracted from the original + // document, which provides precise and contextually relevant answer to + // the search query. + // + // If the number of matching answers is less than the + // extractive_answer_count, return all of the answers; otherwise, return + // the extractive_answer_count. + // + // At most 5 answers will be returned for each SearchResult. + int32 max_extractive_answer_count = 1; + + // The max number of extractive segments returned in each search result. + // + // An extractive segment is a text segment extracted from the original + // document which is relevant to the search query and in general more + // verbose than an extrative answer. The segment could then be used as + // input for LLMs to generate summaries and answers. + // + // If the number of matching segments is less than the + // max_extractive_segment_count, return all of the segments; otherwise, + // return the max_extractive_segment_count. + // + // Currently one segment will be returned for each SearchResult. + int32 max_extractive_segment_count = 2; + } + + // If there is no snippet spec provided, there will be no snippet in the + // search result. + SnippetSpec snippet_spec = 1; + + // If there is no summary spec provided, there will be no summary in the + // search response. + SummarySpec summary_spec = 2; + + // If there is no extractive_content_spec provided, there will be no + // extractive answer in the search response. + ExtractiveContentSpec extractive_content_spec = 3; + } + + // Required. The resource name of the Search serving config, such as + // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + // This field is used to identify the serving configuration name, set + // of models used to make the search. + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/ServingConfig" + } + ]; + + // The branch resource name, such as + // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + // + // Use `default_branch` as the branch ID or leave this field empty, to search + // documents under the default branch. + string branch = 2 [(google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Branch" + }]; + + // Raw search query. + string query = 3; + + // Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]s + // to return. If unspecified, defaults to a reasonable value. The maximum + // allowed value is 100. Values above 100 will be coerced to 100. + // + // If this field is negative, an `INVALID_ARGUMENT` is returned. + int32 page_size = 4; + + // A page token received from a previous + // [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] + // must match the call that provided the page token. Otherwise, an + // `INVALID_ARGUMENT` error is returned. + string page_token = 5; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the + // [Document][google.cloud.discoveryengine.v1beta.Document]s deemed by the API + // as relevant) in search results. This field is only considered if + // [page_token][google.cloud.discoveryengine.v1beta.SearchRequest.page_token] + // is unset. + // + // If this field is negative, an `INVALID_ARGUMENT` is returned. + int32 offset = 6; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the documents being filtered. Filter + // expression is case-sensitive. + // + // If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + string filter = 7; + + // The order in which documents are returned. Document can be ordered by + // a field in an [Document][google.cloud.discoveryengine.v1beta.Document] + // object. Leave it unset if ordered by relevance. OrderBy expression is + // case-sensitive. + // + // If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + string order_by = 8; + + // Information about the end user. + // Highly recommended for analytics. The user_agent string in UserInfo will + // be used to deduce device_type for analytics. + UserInfo user_info = 21; + + // Facet specifications for faceted search. If empty, no facets are returned. + // + // A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + // error is returned. + repeated FacetSpec facet_specs = 9; + + // Boost specification to boost certain documents. + BoostSpec boost_spec = 10; + + // Additional search parameters. + // + // For public website search only, supported values are: + // + // * `user_country_code`: string. Default empty. If set to non-empty, results + // are restricted or boosted based on the location provided. + // * `search_type`: double. Default empty. Enables non-webpage searching + // depending on the value. The only valid non-default value is 1, + // which enables image searching. + map params = 11; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. + QueryExpansionSpec query_expansion_spec = 13; + + // The spell correction specification that specifies the mode under + // which spell correction will take effect. + SpellCorrectionSpec spell_correction_spec = 14; + + // 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. + // + // This field should NOT have a fixed value such as `unknown_visitor`. + // + // This should be the same identifier as + // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + // and + // [CompleteQueryRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id] + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + string user_pseudo_id = 15; + + // The content search spec that configs the desired behavior of content + // search. + ContentSearchSpec content_search_spec = 24; + + // Whether to turn on safe search. This is only supported for + // [ContentConfig.PUBLIC_WEBSITE][]. + bool safe_search = 20; + + // The user 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. + map user_labels = 22; +} + +// Response message for +// [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] +// method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Document.id][google.cloud.discoveryengine.v1beta.Document.id] of the + // searched [Document][google.cloud.discoveryengine.v1beta.Document]. + string id = 1; + + // The document data snippet in the search response. Only fields that are + // marked as retrievable are populated. + Document document = 2; + } + + // A facet result. + message Facet { + // A facet value which contains value names and their count. + message FacetValue { + // A facet value which contains values. + oneof facet_value { + // Text value of a facet, such as "Black" for facet "colors". + string value = 1; + + // Interval value for a facet, such as [10, 20) for facet "price". It + // matches + // [SearchRequest.FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. + Interval interval = 2; + } + + // Number of items that have this facet value. + int64 count = 3; + } + + // The key for this facet. E.g., "colors" or "price". It matches + // [SearchRequest.FacetSpec.FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key]. + string key = 1; + + // The facet values for this field. + repeated FacetValue values = 2; + + // Whether the facet is dynamically generated. + bool dynamic_facet = 3; + } + + // Guided search result. The guided search helps user to refine the search + // results and narrow down to the real needs from a broaded search results. + message GuidedSearchResult { + // Useful attribute for search result refinements. + message RefinementAttribute { + // Attribute key used to refine the results e.g. 'movie_type'. + string attribute_key = 1; + + // Attribute value used to refine the results e.g. 'drama'. + string attribute_value = 2; + } + + // A list of ranked refinement attributes. + repeated RefinementAttribute refinement_attributes = 1; + } + + // Summary of the top N search result specified by the summary spec. + message Summary { + // The summary content. + string summary_text = 1; + } + + // A list of matched documents. The order represents the ranking. + repeated SearchResult results = 1; + + // Results of facets requested by user. + repeated Facet facets = 2; + + // Guided search result. + GuidedSearchResult guided_search_result = 8; + + // The estimated total count of matched items irrespective of pagination. The + // count of + // [results][google.cloud.discoveryengine.v1beta.SearchResponse.results] + // returned by pagination may be less than the + // [total_size][google.cloud.discoveryengine.v1beta.SearchResponse.total_size] + // that matches. + int32 total_size = 3; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting + // from this search, which enables accurate attribution of search model + // performance. + string attribution_token = 4; + + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search is performed, and only + // [redirect_uri][google.cloud.discoveryengine.v1beta.SearchResponse.redirect_uri] + // and + // [attribution_token][google.cloud.discoveryengine.v1beta.SearchResponse.attribution_token] + // are set in the response. + string redirect_uri = 12; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.discoveryengine.v1beta.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 5; + + // Contains the spell corrected query, if found. If the spell correction type + // is AUTOMATIC, then the search results are based on corrected_query. + // Otherwise the original query is used for search. + string corrected_query = 7; + + // A summary as part of the search results. + // This field is only returned if + // [SearchRequest.ContentSearchSpec.summary_spec][google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.summary_spec] + // is set. + Summary summary = 9; + + // Controls applied as part of the Control service. + repeated string applied_controls = 10; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event.proto new file mode 100644 index 00000000000..4efcf7ca90e --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event.proto @@ -0,0 +1,465 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1beta/common.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// UserEvent captures all metadata information Discovery Engine API needs to +// know about how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // Generic values: + // + // * `search`: Search for Documents. + // * `view-item`: Detailed page view of a Document. + // * `view-item-list`: View of a panel or ordered list of Documents. + // * `view-home-page`: View of the home page. + // * `view-category-page`: View of a category page, e.g. Home > Men > Jeans + // + // Retail-related values: + // + // * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping + // * `purchase`: Purchase an item(s) + // + // Media-related values: + // + // * `media-play`: Start/resume watching a video, playing a song, etc. + // * `media-complete`: Finished or stopped midway through a video, song, etc. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. 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 log in/out of the website. + // + // Do not set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded model + // quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analytics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string user_pseudo_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // Information about the end user. + UserInfo user_info = 4; + + // Should set to true if the request is made directly from the end user, in + // which case the + // [UserEvent.user_info.user_agent][google.cloud.discoveryengine.v1beta.UserInfo.user_agent] + // can be populated from the HTTP request. + // + // This flag should be set only if the API request is made directly from the + // end user such as a mobile app (and not if a gateway or a server is + // processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent]. + bool direct_user_request = 5; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the session_id: + // + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] + // as prefix. + string session_id = 6; + + // Page metadata such as categories and other critical information for certain + // event types such as `view-category-page`. + PageInfo page_info = 7; + + // Token to attribute an API response to user action(s) to trigger the event. + // + // Highly recommended for user events that are the result of + // [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. + // This field enables accurate attribution of recommendation model + // performance. + // + // The value must be one of: + // + // * [PredictResponse.attribution_token][] for events that are the result of + // [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. + // * [SearchResponse.attribution_token][google.cloud.discoveryengine.v1beta.SearchResponse.attribution_token] for events that are the result of + // [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search]. + // * [CompleteQueryResponse.attribution_token][] for events that are the + // result of + // [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery]. + // + // This token enables us to accurately attribute page view or conversion + // completion back to the event and the particular predict response containing + // this clicked/purchased product. If user clicks on product K in the + // recommendation results, pass [PredictResponse.attribution_token][] as a URL + // parameter to product K's page. When recording events on product K's page, + // log the [PredictResponse.attribution_token][] to this field. + string attribution_token = 8; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the documents being filtered. + // + // One example is for `search` events, the associated + // [SearchRequest][google.cloud.discoveryengine.v1beta.SearchRequest] may + // contain a filter expression in + // [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] + // conforming to https://google.aip.dev/160#filtering. + // + // Similarly, for `view-item-list` events that are generated from a + // [RecommendationService.RecommendRequest][], this field may be populated + // directly from [RecommendationService.RecommendRequest.filter][] conforming + // to https://google.aip.dev/160#filtering. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 9; + + // List of Documents associated with this user event. + // + // This field is optional except for the following event types: + // + // * `view-item` + // * `add-to-cart` + // * `purchase` + // * `media-play` + // * `media-complete` + // + // In a `search` event, this field represents the documents returned to the + // end user on the current page (the end user may have not finished browsing + // the whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [UserEvent.documents][google.cloud.discoveryengine.v1beta.UserEvent.documents] + // is desired. + repeated DocumentInfo documents = 10; + + // Panel metadata associated with this user event. + PanelInfo panel = 11; + + // Search API details related to the event. + // + // This field should be set for `search` event. + SearchInfo search_info = 12; + + // CompleteQuery API details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionInfo completion_info = 13; + + // The transaction metadata (if any) associated with this user event. + TransactionInfo transaction_info = 14; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups on the customer end. + repeated string tag_ids = 15; + + // The promotion IDs if this is an event associated with promotions. + // Currently, this field is restricted to at most one ID. + repeated string promotion_ids = 16; + + // Extra user event features to include in the recommendation model. + // These attributes must NOT contain data that needs to be parsed or processed + // further, e.g. JSON or other encodings. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Discovery Engine API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an + // `INVALID_ARGUMENT` error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // ` traffic_channel`, which is how a user arrives at the site. Users can + // arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 17; + + // Media-specific info. + MediaInfo media_info = 18; +} + +// Detailed page information. +message PageInfo { + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string pageview_id = 1; + + // The most specific category associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategory" : "Sales > 2017 Black Friday Deals". + // + // Required for `view-category-page` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string page_category = 2; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 3; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. However, some browser + // privacy restrictions may cause this field to be empty. + string referrer_uri = 4; +} + +// Detailed search information. +message SearchInfo { + // The user's search query. + // + // See + // [SearchRequest.query][google.cloud.discoveryengine.v1beta.SearchRequest.query] + // for definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.discoveryengine.v1beta.SearchInfo.search_query] + // or + // [PageInfo.page_category][google.cloud.discoveryengine.v1beta.PageInfo.page_category] + // is required for `search` events. Other event types should not set this + // field. Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 1; + + // The order in which products are returned, if applicable. + // + // See + // [SearchRequest.order_by][google.cloud.discoveryengine.v1beta.SearchRequest.order_by] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 2; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See + // [SearchRequest.offset][google.cloud.discoveryengine.v1beta.SearchRequest.offset] + // for definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + optional int32 offset = 3; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionInfo { + // End user selected [CompleteQueryResponse.CompletionResult.suggestion][]. + string selected_suggestion = 1; + + // End user selected [CompleteQueryResponse.CompletionResult.suggestion][] + // position, starting from 0. + int32 selected_position = 2; +} + +// A transaction represents the entire purchase transaction. +message TransactionInfo { + // Required. Total non-zero value associated with the transaction. This value + // may include shipping, tax, or other adjustments to the total value that you + // want to include. + optional float value = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency = 2 [(google.api.field_behavior) = REQUIRED]; + + // The transaction ID with a length limit of 128 characters. + string transaction_id = 3; + + // All the taxes associated with the transaction. + optional float tax = 4; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = + // [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - + // [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - + // [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] + optional float cost = 5; + + // The total discount(s) value applied to this transaction. + // This figure should be excluded from + // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + // + // For example, if a user paid + // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + // amount, then nominal (pre-discount) value of the transaction is the sum of + // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] + // and + // [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] + // + // This means that profit is calculated the same way, regardless of the + // discount value, and that + // [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] + // can be larger than + // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value]: + // + // * Profit = + // [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - + // [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - + // [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] + optional float discount_value = 6; +} + +// Detailed document information associated with a user event. +message DocumentInfo { + // A required descriptor of the associated + // [Document][google.cloud.discoveryengine.v1beta.Document]. + // + // * If [id][google.cloud.discoveryengine.v1beta.DocumentInfo.id] is + // specified, then the default values for + // `{location}`, `{collection_id}`, `{data_store_id}`, and `{branch_id}` are + // used when annotating with the stored Document. + // + // * If [name][google.cloud.discoveryengine.v1beta.DocumentInfo.name] is + // specified, then the provided values (default values allowed) for + // `{location}`, `{collection_id}`, `{data_store_id}`, and + // `{branch_id}` are used when annotating with the stored Document. + oneof document_descriptor { + // Required. The Document resource ID. + string id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The Document resource full name, of the form: + // `projects/{project_id}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}` + string name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/Document" + } + ]; + } + + // Quantity of the Document associated with the user event. Defaults to 1. + // + // For example, this field will be 2 if two quantities of the same Document + // are involved in a `add-to-cart` event. + // + // Required for events of the following event types: + // + // * `add-to-cart` + // * `purchase` + optional int32 quantity = 3; + + // The promotion IDs associated with this Document. + // Currently, this field is restricted to at most one ID. + repeated string promotion_ids = 4; +} + +// Detailed panel information associated with a user event. +message PanelInfo { + // Required. The panel ID. + string panel_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // The display name of the panel. + string display_name = 3; + + // The ordered position of the panel, if shown to the user with other panels. + // If set, then + // [total_panels][google.cloud.discoveryengine.v1beta.PanelInfo.total_panels] + // must also be set. + optional int32 panel_position = 4; + + // The total number of panels, including this one, shown to the user. + // Must be set if + // [panel_position][google.cloud.discoveryengine.v1beta.PanelInfo.panel_position] + // is set. + optional int32 total_panels = 5; +} + +// Media-specific user event information. +message MediaInfo { + // The media progress time in seconds, if applicable. + // For example, if the end user has finished 90 seconds of a playback video, + // then [MediaInfo.media_progress_duration.seconds][Duration.seconds] should + // be set to 90. + google.protobuf.Duration media_progress_duration = 1; + + // Media progress should be computed using only the media_progress_duration + // relative to the media total length. + // + // This value must be between `[0, 1.0]` inclusive. + // + // If this is not a playback or the progress cannot be computed (e.g. ongoing + // livestream), this field should be unset. + optional float media_progress_percentage = 2; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event_service.proto new file mode 100644 index 00000000000..de59b0c2faa --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event_service.proto @@ -0,0 +1,133 @@ +// 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.discoveryengine.v1beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/api/resource.proto"; +import "google/cloud/discoveryengine/v1beta/import_config.proto"; +import "google/cloud/discoveryengine/v1beta/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; +option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.discoveryengine.v1beta"; +option objc_class_prefix = "DISCOVERYENGINE"; +option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; +option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; + +// Service for ingesting end user actions on a website to Discovery Engine API. +service UserEventService { + option (google.api.default_host) = "discoveryengine.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*/locations/*/dataStores/*}/userEvents:write" + body: "user_event" + additional_bindings { + post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:write" + body: "user_event" + } + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Discovery Engine API JavaScript pixel and + // Google Tag Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v1beta/{parent=projects/*/locations/*/dataStores/*}/userEvents:collect" + additional_bindings { + get: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:collect" + } + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // Operation.response is of type ImportResponse. Note that it is + // possible for a subset of the items to be successfully inserted. + // Operation.metadata is of type ImportMetadata. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta/{parent=projects/*/locations/*/dataStores/*}/userEvents:import" + body: "*" + additional_bindings { + post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:import" + body: "*" + } + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.discoveryengine.v1beta.ImportUserEventsResponse" + metadata_type: "google.cloud.discoveryengine.v1beta.ImportUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent DataStore resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // Required. User event to write. + optional UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent DataStore resource name, such as + // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "discoveryengine.googleapis.com/DataStore" + } + ]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // 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. + optional string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + optional int64 ets = 4; +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/completion_service.complete_query.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/completion_service.complete_query.js new file mode 100644 index 00000000000..9100d412b8a --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/completion_service.complete_query.js @@ -0,0 +1,101 @@ +// Copyright 2023 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(dataStore, query) { + // [START discoveryengine_v1beta_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. The parent data store resource name for which the completion is + * performed, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store`. + */ + // const dataStore = 'abc123' + /** + * Required. The typeahead input used to fetch suggestions. Maximum length is + * 128 characters. + */ + // const query = 'abc123' + /** + * Selects data model of query suggestions for serving. Currently supported + * values: + * * `document` - Using suggestions generated from user-imported documents. + * * `search-history` - Using suggestions generated from the past history of + * SearchService.Search google.cloud.discoveryengine.v1beta.SearchService.Search + * API calls. Do not use it when there is no traffic for Search API. + * * `user-event` - Using suggestions generated from user-imported search + * events. + * * `document-completable` - Using suggestions taken directly from + * user-imported document fields marked as completable. + * Default values: + * * `document` is the default model for regular dataStores. + * * `search-history` is the default model for + * IndustryVertical.SITE_SEARCH google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH + * dataStores. + */ + // const queryModel = 'abc123' + /** + * 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. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * UserEvent.user_pseudo_id google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id + * and + * SearchRequest.user_pseudo_id google.cloud.discoveryengine.v1beta.SearchRequest.user_pseudo_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + */ + // const userPseudoId = 'abc123' + + // Imports the Discoveryengine library + const {CompletionServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + dataStore, + query, + }; + + // Run request + const response = await discoveryengineClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END discoveryengine_v1beta_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.create_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.create_document.js new file mode 100644 index 00000000000..e0c966b4a4a --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.create_document.js @@ -0,0 +1,86 @@ +// Copyright 2023 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, document, documentId) { + // [START discoveryengine_v1beta_generated_DocumentService_CreateDocument_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 resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + */ + // const parent = 'abc123' + /** + * Required. The Document google.cloud.discoveryengine.v1beta.Document to + * create. + */ + // const document = {} + /** + * Required. The ID to use for the + * Document google.cloud.discoveryengine.v1beta.Document, which will become + * the final component of the + * Document.name google.cloud.discoveryengine.v1beta.Document.name. + * If the caller does not have permission to create the + * Document google.cloud.discoveryengine.v1beta.Document, regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * This field must be unique among all + * Document google.cloud.discoveryengine.v1beta.Document s with the same + * parent google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent. + * Otherwise, an `ALREADY_EXISTS` error is returned. + * This field must conform to RFC-1034 (https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + */ + // const documentId = 'abc123' + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callCreateDocument() { + // Construct request + const request = { + parent, + document, + documentId, + }; + + // Run request + const response = await discoveryengineClient.createDocument(request); + console.log(response); + } + + callCreateDocument(); + // [END discoveryengine_v1beta_generated_DocumentService_CreateDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.delete_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.delete_document.js new file mode 100644 index 00000000000..e51c6883909 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.delete_document.js @@ -0,0 +1,68 @@ +// Copyright 2023 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 discoveryengine_v1beta_generated_DocumentService_DeleteDocument_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 + * Document google.cloud.discoveryengine.v1beta.Document, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to delete the + * Document google.cloud.discoveryengine.v1beta.Document, regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the Document google.cloud.discoveryengine.v1beta.Document to delete + * does not exist, a `NOT_FOUND` error is returned. + */ + // const name = 'abc123' + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callDeleteDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await discoveryengineClient.deleteDocument(request); + console.log(response); + } + + callDeleteDocument(); + // [END discoveryengine_v1beta_generated_DocumentService_DeleteDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.get_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.get_document.js new file mode 100644 index 00000000000..2cfdd06e7c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.get_document.js @@ -0,0 +1,68 @@ +// Copyright 2023 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 discoveryengine_v1beta_generated_DocumentService_GetDocument_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 + * Document google.cloud.discoveryengine.v1beta.Document, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * If the caller does not have permission to access the + * Document google.cloud.discoveryengine.v1beta.Document, regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the requested Document google.cloud.discoveryengine.v1beta.Document + * does not exist, a `NOT_FOUND` error is returned. + */ + // const name = 'abc123' + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callGetDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await discoveryengineClient.getDocument(request); + console.log(response); + } + + callGetDocument(); + // [END discoveryengine_v1beta_generated_DocumentService_GetDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.import_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.import_documents.js new file mode 100644 index 00000000000..d737f12f8d3 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.import_documents.js @@ -0,0 +1,136 @@ +// Copyright 2023 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 discoveryengine_v1beta_generated_DocumentService_ImportDocuments_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 Inline source for the input content for documents. + */ + // const inlineSource = {} + /** + * Cloud Storage location for the input content. + */ + // const gcsSource = {} + /** + * BigQuery input source. + */ + // const bigquerySource = {} + /** + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Requires create/update permission. + */ + // const parent = 'abc123' + /** + * The desired location of errors incurred during the Import. + */ + // const errorConfig = {} + /** + * The mode of reconciliation between existing documents and the documents to + * be imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Whether to automatically generate IDs for the documents if absent. + * If set to `true`, + * Document.id google.cloud.discoveryengine.v1beta.Document.id s are + * automatically generated based on the hash of the payload, where IDs may not + * be consistent during multiple imports. In which case + * ReconciliationMode.FULL google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.FULL + * is highly recommended to avoid duplicate contents. If unset or set to + * `false`, Document.id google.cloud.discoveryengine.v1beta.Document.id s + * have to be specified using + * id_field google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.id_field, + * otherwises, documents without IDs will fail to be imported. + * Only set this field when using + * GcsSource google.cloud.discoveryengine.v1beta.GcsSource or + * BigQuerySource google.cloud.discoveryengine.v1beta.BigQuerySource, and + * when + * GcsSource.data_schema google.cloud.discoveryengine.v1beta.GcsSource.data_schema + * or + * BigQuerySource.data_schema google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema + * is `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown. + */ + // const autoGenerateIds = true + /** + * The field in the Cloud Storage and BigQuery sources that indicates the + * unique IDs of the documents. + * For GcsSource google.cloud.discoveryengine.v1beta.GcsSource it is the + * key of the JSON field. For instance, `my_id` for JSON `{"my_id": + * "some_uuid"}`. For + * BigQuerySource google.cloud.discoveryengine.v1beta.BigQuerySource it is + * the column name of the BigQuery table where the unique ids are stored. + * The values of the JSON field or the BigQuery column will be used as the + * Document.id google.cloud.discoveryengine.v1beta.Document.id s. The JSON + * field or the BigQuery column must be of string type, and the values must be + * set as valid strings conform to + * RFC-1034 (https://tools.ietf.org/html/rfc1034) with 1-63 characters. + * Otherwise, documents without valid IDs will fail to be imported. + * Only set this field when using + * GcsSource google.cloud.discoveryengine.v1beta.GcsSource or + * BigQuerySource google.cloud.discoveryengine.v1beta.BigQuerySource, and + * when + * GcsSource.data_schema google.cloud.discoveryengine.v1beta.GcsSource.data_schema + * or + * BigQuerySource.data_schema google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema + * is `custom`. And only set this field when + * auto_generate_ids google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.auto_generate_ids + * is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. + * If it is unset, a default value `_id` is used when importing from the + * allowed data sources. + */ + // const idField = 'abc123' + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callImportDocuments() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await discoveryengineClient.importDocuments(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportDocuments(); + // [END discoveryengine_v1beta_generated_DocumentService_ImportDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.list_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.list_documents.js new file mode 100644 index 00000000000..8df3c1c231a --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.list_documents.js @@ -0,0 +1,88 @@ +// Copyright 2023 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 discoveryengine_v1beta_generated_DocumentService_ListDocuments_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/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * If the caller does not have permission to list Documents s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Document google.cloud.discoveryengine.v1beta.Document 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 + * ListDocumentsResponse.next_page_token google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token, + * received from a previous + * DocumentService.ListDocuments google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * DocumentService.ListDocuments google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callListDocuments() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await discoveryengineClient.listDocumentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListDocuments(); + // [END discoveryengine_v1beta_generated_DocumentService_ListDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.purge_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.purge_documents.js new file mode 100644 index 00000000000..401b9486ac5 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.purge_documents.js @@ -0,0 +1,75 @@ +// Copyright 2023 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 discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_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 resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + */ + // const parent = 'abc123' + /** + * Required. Filter matching documents to purge. Only currently supported + * value is + * `*` (all items). + */ + // const filter = 'abc123' + /** + * Actually performs the purge. If `force` is set to false, return the + * expected purge count without deleting any documents. + */ + // const force = true + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callPurgeDocuments() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await discoveryengineClient.purgeDocuments(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeDocuments(); + // [END discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.update_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.update_document.js new file mode 100644 index 00000000000..30d95c05426 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.update_document.js @@ -0,0 +1,75 @@ +// Copyright 2023 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(document) { + // [START discoveryengine_v1beta_generated_DocumentService_UpdateDocument_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 document to update/create. + * If the caller does not have permission to update the + * Document google.cloud.discoveryengine.v1beta.Document, regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * If the Document google.cloud.discoveryengine.v1beta.Document to update + * does not exist and + * allow_missing google.cloud.discoveryengine.v1beta.UpdateDocumentRequest.allow_missing + * is not set, a `NOT_FOUND` error is returned. + */ + // const document = {} + /** + * If set to true, and the + * Document google.cloud.discoveryengine.v1beta.Document is not found, a + * new Document google.cloud.discoveryengine.v1beta.Document will be + * created. + */ + // const allowMissing = true + + // Imports the Discoveryengine library + const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new DocumentServiceClient(); + + async function callUpdateDocument() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await discoveryengineClient.updateDocument(request); + console.log(response); + } + + callUpdateDocument(); + // [END discoveryengine_v1beta_generated_DocumentService_UpdateDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/recommendation_service.recommend.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/recommendation_service.recommend.js new file mode 100644 index 00000000000..334741b9a48 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/recommendation_service.recommend.js @@ -0,0 +1,157 @@ +// Copyright 2023 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, userEvent) { + // [START discoveryengine_v1beta_generated_RecommendationService_Recommend_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: + * `projects/* /locations/global/collections/* /dataStores/* /servingConfigs/*` + * Before you can request recommendations from your model, you must create at + * least one serving config for it. + */ + // const servingConfig = 'abc123' + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the Recommend 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.user_pseudo_id google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id + * or + * UserEvent.user_info.user_id google.cloud.discoveryengine.v1beta.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.user_pseudo_id google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id + * to a random unique ID and leave + * UserEvent.user_info.user_id google.cloud.discoveryengine.v1beta.UserInfo.user_id + * unset. + */ + // const userEvent = {} + /** + * Maximum number of results to return. Set this property + * to the number of recommendation 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 + /** + * Filter for restricting recommendation results with a length limit of 5,000 + * characters. Currently, only filter expressions on the `filter_tags` + * attribute is supported. + * Examples: + * * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))` + * * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))` + * If your filter blocks all results, the API will return generic + * (unfiltered) popular Documents. If you only want results strictly matching + * the filters, set `strictFiltering` to True in + * RecommendRequest.params google.cloud.discoveryengine.v1beta.RecommendRequest.params + * to receive empty results instead. + * Note that the API will never return + * Document google.cloud.discoveryengine.v1beta.Document s with + * `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices. + */ + // const filter = 'abc123' + /** + * Use validate only mode for this recommendation query. If set to true, a + * fake model will be used that returns arbitrary Document IDs. + * 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 recommendations. + * Allowed values: + * * `returnDocument`: Boolean. If set to true, the associated Document + * object will be returned in + * RecommendResponse.RecommendationResult.document google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document. + * * `returnScore`: Boolean. If set to true, the recommendation 'score' + * corresponding to each returned Document will be set in + * RecommendResponse.RecommendationResult.metadata google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata. + * The given 'score' indicates the probability of a Document conversion + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular Documents instead of empty if + * your filter blocks all recommendation results. + * * `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 recommendation results + * based on Document category. + */ + // const params = 1234 + /** + * The user 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 Requirements for + * labels (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const userLabels = 1234 + + // Imports the Discoveryengine library + const {RecommendationServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new RecommendationServiceClient(); + + async function callRecommend() { + // Construct request + const request = { + servingConfig, + userEvent, + }; + + // Run request + const response = await discoveryengineClient.recommend(request); + console.log(response); + } + + callRecommend(); + // [END discoveryengine_v1beta_generated_RecommendationService_Recommend_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.create_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.create_schema.js new file mode 100644 index 00000000000..0454db4f0eb --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.create_schema.js @@ -0,0 +1,80 @@ +// Copyright 2023 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, schema, schemaId) { + // [START discoveryengine_v1beta_generated_SchemaService_CreateSchema_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 data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + */ + // const parent = 'abc123' + /** + * Required. The Schema google.cloud.discoveryengine.v1beta.Schema to + * create. + */ + // const schema = {} + /** + * Required. The ID to use for the + * Schema google.cloud.discoveryengine.v1beta.Schema, which will become the + * final component of the + * Schema.name google.cloud.discoveryengine.v1beta.Schema.name. + * This field should conform to + * RFC-1034 (https://tools.ietf.org/html/rfc1034) standard with a length + * limit of 63 characters. + */ + // const schemaId = 'abc123' + + // Imports the Discoveryengine library + const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new SchemaServiceClient(); + + async function callCreateSchema() { + // Construct request + const request = { + parent, + schema, + schemaId, + }; + + // Run request + const [operation] = await discoveryengineClient.createSchema(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateSchema(); + // [END discoveryengine_v1beta_generated_SchemaService_CreateSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.delete_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.delete_schema.js new file mode 100644 index 00000000000..01e8dcd4bb6 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.delete_schema.js @@ -0,0 +1,63 @@ +// Copyright 2023 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 discoveryengine_v1beta_generated_SchemaService_DeleteSchema_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 full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + */ + // const name = 'abc123' + + // Imports the Discoveryengine library + const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new SchemaServiceClient(); + + async function callDeleteSchema() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await discoveryengineClient.deleteSchema(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteSchema(); + // [END discoveryengine_v1beta_generated_SchemaService_DeleteSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.get_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.get_schema.js new file mode 100644 index 00000000000..d537a5aa94d --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.get_schema.js @@ -0,0 +1,62 @@ +// Copyright 2023 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 discoveryengine_v1beta_generated_SchemaService_GetSchema_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 full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + */ + // const name = 'abc123' + + // Imports the Discoveryengine library + const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new SchemaServiceClient(); + + async function callGetSchema() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await discoveryengineClient.getSchema(request); + console.log(response); + } + + callGetSchema(); + // [END discoveryengine_v1beta_generated_SchemaService_GetSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.list_schemas.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.list_schemas.js new file mode 100644 index 00000000000..6c9338fc60e --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.list_schemas.js @@ -0,0 +1,81 @@ +// Copyright 2023 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 discoveryengine_v1beta_generated_SchemaService_ListSchemas_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 data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + */ + // const parent = 'abc123' + /** + * The maximum number of Schema google.cloud.discoveryengine.v1beta.Schema s + * to return. The service may return fewer than this value. + * If unspecified, at most 100 + * Schema google.cloud.discoveryengine.v1beta.Schema s will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + */ + // const pageSize = 1234 + /** + * A page token, received from a previous + * SchemaService.ListSchemas google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SchemaService.ListSchemas google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas + * must match the call that provided the page token. + */ + // const pageToken = 'abc123' + + // Imports the Discoveryengine library + const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new SchemaServiceClient(); + + async function callListSchemas() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await discoveryengineClient.listSchemasAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListSchemas(); + // [END discoveryengine_v1beta_generated_SchemaService_ListSchemas_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.update_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.update_schema.js new file mode 100644 index 00000000000..54343865e4a --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.update_schema.js @@ -0,0 +1,70 @@ +// Copyright 2023 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(schema) { + // [START discoveryengine_v1beta_generated_SchemaService_UpdateSchema_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 Schema google.cloud.discoveryengine.v1beta.Schema to + * update. + */ + // const schema = {} + /** + * If set to true, and the + * Schema google.cloud.discoveryengine.v1beta.Schema is not found, a new + * Schema google.cloud.discoveryengine.v1beta.Schema will be created. In + * this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Discoveryengine library + const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new SchemaServiceClient(); + + async function callUpdateSchema() { + // Construct request + const request = { + schema, + }; + + // Run request + const [operation] = await discoveryengineClient.updateSchema(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateSchema(); + // [END discoveryengine_v1beta_generated_SchemaService_UpdateSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/search_service.search.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/search_service.search.js new file mode 100644 index 00000000000..0ff32021830 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/search_service.search.js @@ -0,0 +1,197 @@ +// Copyright 2023 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 discoveryengine_v1beta_generated_SearchService_Search_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 Search serving config, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + */ + // const servingConfig = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + */ + // const query = 'abc123' + /** + * Maximum number of Document google.cloud.discoveryengine.v1beta.Document s + * to return. If unspecified, defaults to a reasonable value. The maximum + * allowed value is 100. Values above 100 will be coerced to 100. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + */ + // const pageSize = 1234 + /** + * A page token received from a previous + * SearchService.Search google.cloud.discoveryengine.v1beta.SearchService.Search + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.discoveryengine.v1beta.SearchService.Search + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * Document google.cloud.discoveryengine.v1beta.Document s deemed by the API + * as relevant) in search results. This field is only considered if + * page_token google.cloud.discoveryengine.v1beta.SearchRequest.page_token + * is unset. + * If this field is negative, an `INVALID_ARGUMENT` is returned. + */ + // const offset = 1234 + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. Filter + * expression is case-sensitive. + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + */ + // const filter = 'abc123' + /** + * The order in which documents are returned. Document can be ordered by + * a field in an Document google.cloud.discoveryengine.v1beta.Document + * object. Leave it unset if ordered by relevance. OrderBy expression is + * case-sensitive. + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + */ + // const orderBy = 'abc123' + /** + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + */ + // const userInfo = {} + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + */ + // const facetSpecs = 1234 + /** + * Boost specification to boost certain documents. + */ + // const boostSpec = {} + /** + * Additional search parameters. + * For public website search only, supported values are: + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + */ + // const params = 1234 + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + */ + // const queryExpansionSpec = {} + /** + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + */ + // const spellCorrectionSpec = {} + /** + * 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. + * This field should NOT have a fixed value such as `unknown_visitor`. + * This should be the same identifier as + * UserEvent.user_pseudo_id google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id + * and + * CompleteQueryRequest.user_pseudo_id google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + */ + // const userPseudoId = 'abc123' + /** + * The content search spec that configs the desired behavior of content + * search. + */ + // const contentSearchSpec = {} + /** + * Whether to turn on safe search. This is only supported for + * ContentConfig.PUBLIC_WEBSITE . + */ + // const safeSearch = true + /** + * The user 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 userLabels = 1234 + + // Imports the Discoveryengine library + const {SearchServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + servingConfig, + }; + + // Run request + const iterable = await discoveryengineClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END discoveryengine_v1beta_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json new file mode 100644 index 00000000000..8ff518f4eac --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json @@ -0,0 +1,947 @@ +{ + "clientLibrary": { + "name": "nodejs-discoveryengine", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.discoveryengine.v1beta", + "version": "v1beta" + } + ] + }, + "snippets": [ + { + "regionTag": "discoveryengine_v1beta_generated_CompletionService_CompleteQuery_async", + "title": "CompletionService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified user input with keyword suggestions.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "data_store", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "query_model", + "type": "TYPE_STRING" + }, + { + "name": "user_pseudo_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1beta.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.discoveryengine.v1beta.CompletionService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_DocumentService_GetDocument_async", + "title": "CompletionService getDocument Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Document][google.cloud.discoveryengine.v1beta.Document].", + "canonical": true, + "file": "document_service.get_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDocument", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.GetDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1beta.Document", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" + }, + "method": { + "shortName": "GetDocument", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.GetDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_DocumentService_ListDocuments_async", + "title": "CompletionService listDocuments Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s.", + "canonical": true, + "file": "document_service.list_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDocuments", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1beta.ListDocumentsResponse", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" + }, + "method": { + "shortName": "ListDocuments", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_DocumentService_CreateDocument_async", + "title": "CompletionService createDocument Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Document][google.cloud.discoveryengine.v1beta.Document].", + "canonical": true, + "file": "document_service.create_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDocument", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.CreateDocument", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "document", + "type": ".google.cloud.discoveryengine.v1beta.Document" + }, + { + "name": "document_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1beta.Document", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" + }, + "method": { + "shortName": "CreateDocument", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.CreateDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_DocumentService_UpdateDocument_async", + "title": "CompletionService updateDocument Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Document][google.cloud.discoveryengine.v1beta.Document].", + "canonical": true, + "file": "document_service.update_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDocument", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.UpdateDocument", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.cloud.discoveryengine.v1beta.Document" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.discoveryengine.v1beta.Document", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" + }, + "method": { + "shortName": "UpdateDocument", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.UpdateDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_DocumentService_DeleteDocument_async", + "title": "CompletionService deleteDocument Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Document][google.cloud.discoveryengine.v1beta.Document].", + "canonical": true, + "file": "document_service.delete_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDocument", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.DeleteDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" + }, + "method": { + "shortName": "DeleteDocument", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.DeleteDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_DocumentService_ImportDocuments_async", + "title": "CompletionService importDocuments Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Document][google.cloud.discoveryengine.v1beta.Document]s. Request processing may be synchronous. Non-existing items will be created. Note: It is possible for a subset of the [Document][google.cloud.discoveryengine.v1beta.Document]s to be successfully updated.", + "canonical": true, + "file": "document_service.import_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 128, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportDocuments", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.ImportDocuments", + "async": true, + "parameters": [ + { + "name": "inline_source", + "type": ".google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.InlineSource" + }, + { + "name": "gcs_source", + "type": ".google.cloud.discoveryengine.v1beta.GcsSource" + }, + { + "name": "bigquery_source", + "type": ".google.cloud.discoveryengine.v1beta.BigQuerySource" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "error_config", + "type": ".google.cloud.discoveryengine.v1beta.ImportErrorConfig" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode" + }, + { + "name": "auto_generate_ids", + "type": "TYPE_BOOL" + }, + { + "name": "id_field", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" + }, + "method": { + "shortName": "ImportDocuments", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.ImportDocuments", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_async", + "title": "CompletionService purgeDocuments Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes all selected [Document][google.cloud.discoveryengine.v1beta.Document]s in a branch. This process is asynchronous. Depending on the number of [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, this operation can take hours to complete. Before the delete operation completes, some [Document][google.cloud.discoveryengine.v1beta.Document]s might still be returned by [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument] or [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments]. To get a list of the [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, set [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force] to false.", + "canonical": true, + "file": "document_service.purge_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeDocuments", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.PurgeDocuments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" + }, + "method": { + "shortName": "PurgeDocuments", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.PurgeDocuments", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_RecommendationService_Recommend_async", + "title": "CompletionService recommend Sample", + "origin": "API_DEFINITION", + "description": " Makes a recommendation, which requires a contextual user event.", + "canonical": true, + "file": "recommendation_service.recommend.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 149, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Recommend", + "fullName": "google.cloud.discoveryengine.v1beta.RecommendationService.Recommend", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.discoveryengine.v1beta.UserEvent" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "user_labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.discoveryengine.v1beta.RecommendResponse", + "client": { + "shortName": "RecommendationServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.RecommendationServiceClient" + }, + "method": { + "shortName": "Recommend", + "fullName": "google.cloud.discoveryengine.v1beta.RecommendationService.Recommend", + "service": { + "shortName": "RecommendationService", + "fullName": "google.cloud.discoveryengine.v1beta.RecommendationService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_SchemaService_GetSchema_async", + "title": "CompletionService getSchema Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Schema][google.cloud.discoveryengine.v1beta.Schema].", + "canonical": true, + "file": "schema_service.get_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetSchema", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.GetSchema", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1beta.Schema", + "client": { + "shortName": "SchemaServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaServiceClient" + }, + "method": { + "shortName": "GetSchema", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.GetSchema", + "service": { + "shortName": "SchemaService", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_SchemaService_ListSchemas_async", + "title": "CompletionService listSchemas Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Schema][google.cloud.discoveryengine.v1beta.Schema]s.", + "canonical": true, + "file": "schema_service.list_schemas.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListSchemas", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.discoveryengine.v1beta.ListSchemasResponse", + "client": { + "shortName": "SchemaServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaServiceClient" + }, + "method": { + "shortName": "ListSchemas", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas", + "service": { + "shortName": "SchemaService", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_SchemaService_CreateSchema_async", + "title": "CompletionService createSchema Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Schema][google.cloud.discoveryengine.v1beta.Schema].", + "canonical": true, + "file": "schema_service.create_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSchema", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.CreateSchema", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "schema", + "type": ".google.cloud.discoveryengine.v1beta.Schema" + }, + { + "name": "schema_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SchemaServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaServiceClient" + }, + "method": { + "shortName": "CreateSchema", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.CreateSchema", + "service": { + "shortName": "SchemaService", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_SchemaService_UpdateSchema_async", + "title": "CompletionService updateSchema Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Schema][google.cloud.discoveryengine.v1beta.Schema].", + "canonical": true, + "file": "schema_service.update_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateSchema", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.UpdateSchema", + "async": true, + "parameters": [ + { + "name": "schema", + "type": ".google.cloud.discoveryengine.v1beta.Schema" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SchemaServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaServiceClient" + }, + "method": { + "shortName": "UpdateSchema", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.UpdateSchema", + "service": { + "shortName": "SchemaService", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_SchemaService_DeleteSchema_async", + "title": "CompletionService deleteSchema Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Schema][google.cloud.discoveryengine.v1beta.Schema].", + "canonical": true, + "file": "schema_service.delete_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteSchema", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.DeleteSchema", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "SchemaServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaServiceClient" + }, + "method": { + "shortName": "DeleteSchema", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.DeleteSchema", + "service": { + "shortName": "SchemaService", + "fullName": "google.cloud.discoveryengine.v1beta.SchemaService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_SearchService_Search_async", + "title": "CompletionService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 189, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.discoveryengine.v1beta.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "user_info", + "type": ".google.cloud.discoveryengine.v1beta.UserInfo" + }, + { + "name": "facet_specs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "boost_spec", + "type": ".google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec" + }, + { + "name": "spell_correction_spec", + "type": ".google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec" + }, + { + "name": "user_pseudo_id", + "type": "TYPE_STRING" + }, + { + "name": "content_search_spec", + "type": ".google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec" + }, + { + "name": "safe_search", + "type": "TYPE_BOOL" + }, + { + "name": "user_labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.discoveryengine.v1beta.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.discoveryengine.v1beta.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.discoveryengine.v1beta.SearchService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_UserEventService_WriteUserEvent_async", + "title": "CompletionService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.discoveryengine.v1beta.UserEvent" + } + ], + "resultType": ".google.cloud.discoveryengine.v1beta.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_UserEventService_CollectUserEvent_async", + "title": "CompletionService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Discovery Engine API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventService" + } + } + } + }, + { + "regionTag": "discoveryengine_v1beta_generated_UserEventService_ImportUserEvents_async", + "title": "CompletionService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "inline_source", + "type": ".google.cloud.discoveryengine.v1beta.ImportUserEventsRequest.InlineSource" + }, + { + "name": "gcs_source", + "type": ".google.cloud.discoveryengine.v1beta.GcsSource" + }, + { + "name": "bigquery_source", + "type": ".google.cloud.discoveryengine.v1beta.BigQuerySource" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "error_config", + "type": ".google.cloud.discoveryengine.v1beta.ImportErrorConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.discoveryengine.v1beta.UserEventService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.collect_user_event.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.collect_user_event.js new file mode 100644 index 00000000000..c77b763bec4 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.collect_user_event.js @@ -0,0 +1,81 @@ +// Copyright 2023 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 discoveryengine_v1beta_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 DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + */ + // 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 Discoveryengine library + const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await discoveryengineClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END discoveryengine_v1beta_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.import_user_events.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.import_user_events.js new file mode 100644 index 00000000000..536d06ef174 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.import_user_events.js @@ -0,0 +1,80 @@ +// Copyright 2023 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 discoveryengine_v1beta_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. + */ + /** + * The Inline source for the input content for UserEvents. + */ + // const inlineSource = {} + /** + * Cloud Storage location for the input content. + */ + // const gcsSource = {} + /** + * BigQuery input source. + */ + // const bigquerySource = {} + /** + * Required. Parent DataStore resource name, of the form + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + */ + // const parent = 'abc123' + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorConfig = {} + + // Imports the Discoveryengine library + const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await discoveryengineClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END discoveryengine_v1beta_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.write_user_event.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.write_user_event.js new file mode 100644 index 00000000000..c8b43541973 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.write_user_event.js @@ -0,0 +1,67 @@ +// Copyright 2023 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 discoveryengine_v1beta_generated_UserEventService_WriteUserEvent_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 DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Discoveryengine library + const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1beta; + + // Instantiates a client + const discoveryengineClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await discoveryengineClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END discoveryengine_v1beta_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/index.ts new file mode 100644 index 00000000000..29248adf6e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/index.ts @@ -0,0 +1,35 @@ +// Copyright 2023 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. ** + +import * as v1beta from './v1beta'; +const CompletionServiceClient = v1beta.CompletionServiceClient; +type CompletionServiceClient = v1beta.CompletionServiceClient; +const DocumentServiceClient = v1beta.DocumentServiceClient; +type DocumentServiceClient = v1beta.DocumentServiceClient; +const RecommendationServiceClient = v1beta.RecommendationServiceClient; +type RecommendationServiceClient = v1beta.RecommendationServiceClient; +const SchemaServiceClient = v1beta.SchemaServiceClient; +type SchemaServiceClient = v1beta.SchemaServiceClient; +const SearchServiceClient = v1beta.SearchServiceClient; +type SearchServiceClient = v1beta.SearchServiceClient; +const UserEventServiceClient = v1beta.UserEventServiceClient; +type UserEventServiceClient = v1beta.UserEventServiceClient; +export {v1beta, CompletionServiceClient, DocumentServiceClient, RecommendationServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient}; +export default {v1beta, CompletionServiceClient, DocumentServiceClient, RecommendationServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client.ts new file mode 100644 index 00000000000..e4a14f3c853 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client.ts @@ -0,0 +1,856 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for Auto-Completion. + * @class + * @memberof v1beta + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CompletionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' + ), + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1beta.CompletionService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1beta.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.CompletionService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1beta.CompletionService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const completionServiceStubMethods = + ['completeQuery']; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Completes the specified user input with keyword suggestions. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.dataStore + * Required. The parent data store resource name for which the completion is + * performed, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store`. + * @param {string} request.query + * Required. The typeahead input used to fetch suggestions. Maximum length is + * 128 characters. + * @param {string} request.queryModel + * Selects data model of query suggestions for serving. Currently supported + * values: + * + * * `document` - Using suggestions generated from user-imported documents. + * * `search-history` - Using suggestions generated from the past history of + * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} + * API calls. Do not use it when there is no traffic for Search API. + * * `user-event` - Using suggestions generated from user-imported search + * events. + * * `document-completable` - Using suggestions taken directly from + * user-imported document fields marked as completable. + * + * Default values: + * + * * `document` is the default model for regular dataStores. + * * `search-history` is the default model for + * {@link google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH|IndustryVertical.SITE_SEARCH} + * dataStores. + * @param {string} request.userPseudoId + * 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. + * + * This field should NOT have a fixed value such as `unknown_visitor`. + * + * This should be the same identifier as + * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} + * and + * {@link google.cloud.discoveryengine.v1beta.SearchRequest.user_pseudo_id|SearchRequest.user_pseudo_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.CompleteQueryResponse | CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta/completion_service.complete_query.js + * region_tag:discoveryengine_v1beta_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|undefined, {}|undefined + ]>; + completeQuery( + request: protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request: protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): void; + completeQuery( + request?: protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, + protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'data_store': request.dataStore ?? '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationDataStorePath(project:string,location:string,dataStore:string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client_config.json new file mode 100644 index 00000000000..9839a098d04 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client_config.json @@ -0,0 +1,43 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.CompletionService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "unavailable", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_proto_list.json new file mode 100644 index 00000000000..c90e69baf40 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/discoveryengine/v1beta/common.proto", + "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client.ts new file mode 100644 index 00000000000..0b1ab721514 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client.ts @@ -0,0 +1,1845 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/document_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './document_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting + * {@link google.cloud.discoveryengine.v1beta.Document|Document} information of the + * customer's website. + * @class + * @memberof v1beta + */ +export class DocumentServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + documentServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DocumentServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new DocumentServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DocumentServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}' + ), + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listDocuments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{get: '/v1beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*}/operations',},{get: '/v1beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importDocumentsResponse = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.ImportDocumentsResponse') as gax.protobuf.Type; + const importDocumentsMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.ImportDocumentsMetadata') as gax.protobuf.Type; + const purgeDocumentsResponse = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.PurgeDocumentsResponse') as gax.protobuf.Type; + const purgeDocumentsMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.PurgeDocumentsMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importDocumentsResponse.decode.bind(importDocumentsResponse), + importDocumentsMetadata.decode.bind(importDocumentsMetadata)), + purgeDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeDocumentsResponse.decode.bind(purgeDocumentsResponse), + purgeDocumentsMetadata.decode.bind(purgeDocumentsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1beta.DocumentService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.documentServiceStub) { + return this.documentServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1beta.DocumentService. + this.documentServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.DocumentService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1beta.DocumentService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const documentServiceStubMethods = + ['getDocument', 'listDocuments', 'createDocument', 'updateDocument', 'deleteDocument', 'importDocuments', 'purgeDocuments']; + for (const methodName of documentServiceStubMethods) { + const callPromise = this.documentServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.documentServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets a {@link google.cloud.discoveryengine.v1beta.Document|Document}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.discoveryengine.v1beta.Document|Document}, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * + * If the caller does not have permission to access the + * {@link google.cloud.discoveryengine.v1beta.Document|Document}, regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * + * If the requested {@link google.cloud.discoveryengine.v1beta.Document|Document} + * does not exist, a `NOT_FOUND` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.Document | Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta/document_service.get_document.js + * region_tag:discoveryengine_v1beta_generated_DocumentService_GetDocument_async + */ + getDocument( + request?: protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|undefined, {}|undefined + ]>; + getDocument( + request: protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|null|undefined, + {}|null|undefined>): void; + getDocument( + request: protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|null|undefined, + {}|null|undefined>): void; + getDocument( + request?: protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDocument(request, options, callback); + } +/** + * Creates a {@link google.cloud.discoveryengine.v1beta.Document|Document}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * @param {google.cloud.discoveryengine.v1beta.Document} request.document + * Required. The {@link google.cloud.discoveryengine.v1beta.Document|Document} to + * create. + * @param {string} request.documentId + * Required. The ID to use for the + * {@link google.cloud.discoveryengine.v1beta.Document|Document}, which will become + * the final component of the + * {@link google.cloud.discoveryengine.v1beta.Document.name|Document.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.discoveryengine.v1beta.Document|Document}, regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * + * This field must be unique among all + * {@link google.cloud.discoveryengine.v1beta.Document|Document}s with the same + * {@link google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent|parent}. + * Otherwise, an `ALREADY_EXISTS` error is returned. + * + * This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) + * standard with a length limit of 63 characters. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.Document | Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta/document_service.create_document.js + * region_tag:discoveryengine_v1beta_generated_DocumentService_CreateDocument_async + */ + createDocument( + request?: protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|undefined, {}|undefined + ]>; + createDocument( + request: protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): void; + createDocument( + request: protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): void; + createDocument( + request?: protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createDocument(request, options, callback); + } +/** + * Updates a {@link google.cloud.discoveryengine.v1beta.Document|Document}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.discoveryengine.v1beta.Document} request.document + * Required. The document to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.discoveryengine.v1beta.Document|Document}, regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * + * If the {@link google.cloud.discoveryengine.v1beta.Document|Document} to update + * does not exist and + * {@link google.cloud.discoveryengine.v1beta.UpdateDocumentRequest.allow_missing|allow_missing} + * is not set, a `NOT_FOUND` error is returned. + * @param {boolean} request.allowMissing + * If set to true, and the + * {@link google.cloud.discoveryengine.v1beta.Document|Document} is not found, a + * new {@link google.cloud.discoveryengine.v1beta.Document|Document} will be + * created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.Document | Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta/document_service.update_document.js + * region_tag:discoveryengine_v1beta_generated_DocumentService_UpdateDocument_async + */ + updateDocument( + request?: protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|undefined, {}|undefined + ]>; + updateDocument( + request: protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): void; + updateDocument( + request: protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): void; + updateDocument( + request?: protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IDocument, + protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'document.name': request.document!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateDocument(request, options, callback); + } +/** + * Deletes a {@link google.cloud.discoveryengine.v1beta.Document|Document}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.discoveryengine.v1beta.Document|Document}, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.discoveryengine.v1beta.Document|Document}, regardless of + * whether or not it exists, a `PERMISSION_DENIED` error is returned. + * + * If the {@link google.cloud.discoveryengine.v1beta.Document|Document} to delete + * does not exist, a `NOT_FOUND` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.protobuf.Empty | Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta/document_service.delete_document.js + * region_tag:discoveryengine_v1beta_generated_DocumentService_DeleteDocument_async + */ + deleteDocument( + request?: protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|undefined, {}|undefined + ]>; + deleteDocument( + request: protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): void; + deleteDocument( + request: protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): void; + deleteDocument( + request?: protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteDocument(request, options, callback); + } + +/** + * Bulk import of multiple + * {@link google.cloud.discoveryengine.v1beta.Document|Document}s. Request + * processing may be synchronous. Non-existing items will be created. + * + * Note: It is possible for a subset of the + * {@link google.cloud.discoveryengine.v1beta.Document|Document}s to be + * successfully updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.InlineSource} request.inlineSource + * The Inline source for the input content for documents. + * @param {google.cloud.discoveryengine.v1beta.GcsSource} request.gcsSource + * Cloud Storage location for the input content. + * @param {google.cloud.discoveryengine.v1beta.BigQuerySource} request.bigquerySource + * BigQuery input source. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Requires create/update permission. + * @param {google.cloud.discoveryengine.v1beta.ImportErrorConfig} request.errorConfig + * The desired location of errors incurred during the Import. + * @param {google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing documents and the documents to + * be imported. Defaults to + * {@link google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {boolean} request.autoGenerateIds + * Whether to automatically generate IDs for the documents if absent. + * + * If set to `true`, + * {@link google.cloud.discoveryengine.v1beta.Document.id|Document.id}s are + * automatically generated based on the hash of the payload, where IDs may not + * be consistent during multiple imports. In which case + * {@link google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.FULL|ReconciliationMode.FULL} + * is highly recommended to avoid duplicate contents. If unset or set to + * `false`, {@link google.cloud.discoveryengine.v1beta.Document.id|Document.id}s + * have to be specified using + * {@link google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.id_field|id_field}, + * otherwises, documents without IDs will fail to be imported. + * + * Only set this field when using + * {@link google.cloud.discoveryengine.v1beta.GcsSource|GcsSource} or + * {@link google.cloud.discoveryengine.v1beta.BigQuerySource|BigQuerySource}, and + * when + * {@link google.cloud.discoveryengine.v1beta.GcsSource.data_schema|GcsSource.data_schema} + * or + * {@link google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema|BigQuerySource.data_schema} + * is `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown. + * @param {string} request.idField + * The field in the Cloud Storage and BigQuery sources that indicates the + * unique IDs of the documents. + * + * For {@link google.cloud.discoveryengine.v1beta.GcsSource|GcsSource} it is the + * key of the JSON field. For instance, `my_id` for JSON `{"my_id": + * "some_uuid"}`. For + * {@link google.cloud.discoveryengine.v1beta.BigQuerySource|BigQuerySource} it is + * the column name of the BigQuery table where the unique ids are stored. + * + * The values of the JSON field or the BigQuery column will be used as the + * {@link google.cloud.discoveryengine.v1beta.Document.id|Document.id}s. The JSON + * field or the BigQuery column must be of string type, and the values must be + * set as valid strings conform to + * [RFC-1034](https://tools.ietf.org/html/rfc1034) with 1-63 characters. + * Otherwise, documents without valid IDs will fail to be imported. + * + * Only set this field when using + * {@link google.cloud.discoveryengine.v1beta.GcsSource|GcsSource} or + * {@link google.cloud.discoveryengine.v1beta.BigQuerySource|BigQuerySource}, and + * when + * {@link google.cloud.discoveryengine.v1beta.GcsSource.data_schema|GcsSource.data_schema} + * or + * {@link google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema|BigQuerySource.data_schema} + * is `custom`. And only set this field when + * {@link google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.auto_generate_ids|auto_generate_ids} + * is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. + * + * If it is unset, a default value `_id` is used when importing from the + * allowed data sources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/document_service.import_documents.js + * region_tag:discoveryengine_v1beta_generated_DocumentService_ImportDocuments_async + */ + importDocuments( + request?: protos.google.cloud.discoveryengine.v1beta.IImportDocumentsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importDocuments( + request: protos.google.cloud.discoveryengine.v1beta.IImportDocumentsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importDocuments( + request: protos.google.cloud.discoveryengine.v1beta.IImportDocumentsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importDocuments( + request?: protos.google.cloud.discoveryengine.v1beta.IImportDocumentsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importDocuments(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importDocuments()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/document_service.import_documents.js + * region_tag:discoveryengine_v1beta_generated_DocumentService_ImportDocuments_async + */ + async checkImportDocumentsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importDocuments, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Permanently deletes all selected + * {@link google.cloud.discoveryengine.v1beta.Document|Document}s in a branch. + * + * This process is asynchronous. Depending on the number of + * {@link google.cloud.discoveryengine.v1beta.Document|Document}s to be deleted, + * this operation can take hours to complete. Before the delete operation + * completes, some {@link google.cloud.discoveryengine.v1beta.Document|Document}s + * might still be returned by + * {@link google.cloud.discoveryengine.v1beta.DocumentService.GetDocument|DocumentService.GetDocument} + * or + * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments}. + * + * To get a list of the + * {@link google.cloud.discoveryengine.v1beta.Document|Document}s to be deleted, + * set + * {@link google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force|PurgeDocumentsRequest.force} + * to false. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * @param {string} request.filter + * Required. Filter matching documents to purge. Only currently supported + * value is + * `*` (all items). + * @param {boolean} request.force + * Actually performs the purge. If `force` is set to false, return the + * expected purge count without deleting any documents. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/document_service.purge_documents.js + * region_tag:discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_async + */ + purgeDocuments( + request?: protos.google.cloud.discoveryengine.v1beta.IPurgeDocumentsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + purgeDocuments( + request: protos.google.cloud.discoveryengine.v1beta.IPurgeDocumentsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeDocuments( + request: protos.google.cloud.discoveryengine.v1beta.IPurgeDocumentsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + purgeDocuments( + request?: protos.google.cloud.discoveryengine.v1beta.IPurgeDocumentsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.purgeDocuments(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeDocuments()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/document_service.purge_documents.js + * region_tag:discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_async + */ + async checkPurgeDocumentsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeDocuments, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Gets a list of {@link google.cloud.discoveryengine.v1beta.Document|Document}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * + * If the caller does not have permission to list {@link |Documents}s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}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. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link google.cloud.discoveryengine.v1beta.Document | Document}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDocuments( + request?: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IDocument[], + protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest|null, + protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse + ]>; + listDocuments( + request: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, + protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.IDocument>): void; + listDocuments( + request: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, + protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.IDocument>): void; + listDocuments( + request?: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, + protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.IDocument>, + callback?: PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, + protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.IDocument>): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IDocument[], + protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest|null, + protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listDocuments(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * + * If the caller does not have permission to list {@link |Documents}s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}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. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1beta.Document | Document} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDocumentsStream( + request?: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.createStream( + this.innerApiCalls.listDocuments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listDocuments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. + * Use `default_branch` as the branch ID, to list documents under the default + * branch. + * + * If the caller does not have permission to list {@link |Documents}s under this + * branch, regardless of whether or not this branch exists, a + * `PERMISSION_DENIED` error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}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. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.discoveryengine.v1beta.Document | Document}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1beta/document_service.list_documents.js + * region_tag:discoveryengine_v1beta_generated_DocumentService_ListDocuments_async + */ + listDocumentsAsync( + request?: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.asyncIterate( + this.innerApiCalls['listDocuments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchPath(project:string,location:string,collection:string,dataStore:string,branch:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).branch; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchPath(project:string,location:string,dataStore:string,branch:string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).branch; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.documentServiceStub && !this._terminated) { + return this.documentServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client_config.json new file mode 100644 index 00000000000..386e18b5201 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client_config.json @@ -0,0 +1,82 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.DocumentService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "GetDocument": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListDocuments": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "CreateDocument": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateDocument": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "DeleteDocument": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ImportDocuments": { + "timeout_millis": 300000, + "retry_codes_name": "unavailable", + "retry_params_name": "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876" + }, + "PurgeDocuments": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_proto_list.json new file mode 100644 index 00000000000..c90e69baf40 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/discoveryengine/v1beta/common.proto", + "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/gapic_metadata.json new file mode 100644 index 00000000000..e5bab29651f --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/gapic_metadata.json @@ -0,0 +1,285 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.discoveryengine.v1beta", + "libraryPackage": "@google-cloud/discoveryengine", + "services": { + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + } + } + } + } + }, + "DocumentService": { + "clients": { + "grpc": { + "libraryClient": "DocumentServiceClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "ImportDocuments": { + "methods": [ + "importDocuments" + ] + }, + "PurgeDocuments": { + "methods": [ + "purgeDocuments" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentServiceClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "ImportDocuments": { + "methods": [ + "importDocuments" + ] + }, + "PurgeDocuments": { + "methods": [ + "purgeDocuments" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + } + } + } + } + }, + "RecommendationService": { + "clients": { + "grpc": { + "libraryClient": "RecommendationServiceClient", + "rpcs": { + "Recommend": { + "methods": [ + "recommend" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RecommendationServiceClient", + "rpcs": { + "Recommend": { + "methods": [ + "recommend" + ] + } + } + } + } + }, + "SchemaService": { + "clients": { + "grpc": { + "libraryClient": "SchemaServiceClient", + "rpcs": { + "GetSchema": { + "methods": [ + "getSchema" + ] + }, + "CreateSchema": { + "methods": [ + "createSchema" + ] + }, + "UpdateSchema": { + "methods": [ + "updateSchema" + ] + }, + "DeleteSchema": { + "methods": [ + "deleteSchema" + ] + }, + "ListSchemas": { + "methods": [ + "listSchemas", + "listSchemasStream", + "listSchemasAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SchemaServiceClient", + "rpcs": { + "GetSchema": { + "methods": [ + "getSchema" + ] + }, + "CreateSchema": { + "methods": [ + "createSchema" + ] + }, + "UpdateSchema": { + "methods": [ + "updateSchema" + ] + }, + "DeleteSchema": { + "methods": [ + "deleteSchema" + ] + }, + "ListSchemas": { + "methods": [ + "listSchemas", + "listSchemasStream", + "listSchemasAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/index.ts new file mode 100644 index 00000000000..5f42e7b32db --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/index.ts @@ -0,0 +1,24 @@ +// Copyright 2023 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. ** + +export {CompletionServiceClient} from './completion_service_client'; +export {DocumentServiceClient} from './document_service_client'; +export {RecommendationServiceClient} from './recommendation_service_client'; +export {SchemaServiceClient} from './schema_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client.ts new file mode 100644 index 00000000000..1975118bf9f --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client.ts @@ -0,0 +1,937 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/recommendation_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './recommendation_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for making recommendations. + * @class + * @memberof v1beta + */ +export class RecommendationServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + recommendationServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RecommendationServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new RecommendationServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof RecommendationServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationCollectionDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1beta.RecommendationService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.recommendationServiceStub) { + return this.recommendationServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1beta.RecommendationService. + this.recommendationServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.RecommendationService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1beta.RecommendationService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const recommendationServiceStubMethods = + ['recommend']; + for (const methodName of recommendationServiceStubMethods) { + const callPromise = this.recommendationServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.recommendationServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Makes a recommendation, which requires a contextual user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. Full resource name of the format: + * `projects/* /locations/global/collections/* /dataStores/* /servingConfigs/*` + * + * Before you can request recommendations from your model, you must create at + * least one serving config for it. + * @param {google.cloud.discoveryengine.v1beta.UserEvent} request.userEvent + * Required. Context about the user, what they are looking at and what action + * they took to trigger the Recommend 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 + * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} + * or + * {@link google.cloud.discoveryengine.v1beta.UserInfo.user_id|UserEvent.user_info.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 + * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} + * to a random unique ID and leave + * {@link google.cloud.discoveryengine.v1beta.UserInfo.user_id|UserEvent.user_info.user_id} + * unset. + * @param {number} request.pageSize + * Maximum number of results to return. Set this property + * to the number of recommendation 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. + * @param {string} request.filter + * Filter for restricting recommendation results with a length limit of 5,000 + * characters. Currently, only filter expressions on the `filter_tags` + * attribute is supported. + * + * + * Examples: + * + * * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))` + * * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))` + * + * If your filter blocks all results, the API will return generic + * (unfiltered) popular Documents. If you only want results strictly matching + * the filters, set `strictFiltering` to True in + * {@link google.cloud.discoveryengine.v1beta.RecommendRequest.params|RecommendRequest.params} + * to receive empty results instead. + * + * Note that the API will never return + * {@link google.cloud.discoveryengine.v1beta.Document|Document}s with + * `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices. + * @param {boolean} request.validateOnly + * Use validate only mode for this recommendation query. If set to true, a + * fake model will be used that returns arbitrary Document IDs. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @param {number[]} request.params + * Additional domain specific parameters for the recommendations. + * + * Allowed values: + * + * * `returnDocument`: Boolean. If set to true, the associated Document + * object will be returned in + * {@link google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document|RecommendResponse.RecommendationResult.document}. + * * `returnScore`: Boolean. If set to true, the recommendation 'score' + * corresponding to each returned Document will be set in + * {@link google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata|RecommendResponse.RecommendationResult.metadata}. + * The given 'score' indicates the probability of a Document conversion + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular Documents instead of empty if + * your filter blocks all recommendation results. + * * `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 recommendation results + * based on Document category. + * @param {number[]} request.userLabels + * The user 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 [Requirements for + * labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.RecommendResponse | RecommendResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta/recommendation_service.recommend.js + * region_tag:discoveryengine_v1beta_generated_RecommendationService_Recommend_async + */ + recommend( + request?: protos.google.cloud.discoveryengine.v1beta.IRecommendRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, + protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|undefined, {}|undefined + ]>; + recommend( + request: protos.google.cloud.discoveryengine.v1beta.IRecommendRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, + protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|null|undefined, + {}|null|undefined>): void; + recommend( + request: protos.google.cloud.discoveryengine.v1beta.IRecommendRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, + protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|null|undefined, + {}|null|undefined>): void; + recommend( + request?: protos.google.cloud.discoveryengine.v1beta.IRecommendRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, + protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, + protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, + protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'serving_config': request.servingConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.recommend(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreServingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} serving_config + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreServingConfigPath(project:string,location:string,collection:string,dataStore:string,servingConfig:string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).data_store; + } + + /** + * Parse the serving_config from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).serving_config; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStoreServingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} serving_config + * @returns {string} Resource name string. + */ + projectLocationDataStoreServingConfigPath(project:string,location:string,dataStore:string,servingConfig:string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).data_store; + } + + /** + * Parse the serving_config from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.recommendationServiceStub && !this._terminated) { + return this.recommendationServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client_config.json new file mode 100644 index 00000000000..ceaf901f32b --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client_config.json @@ -0,0 +1,43 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.RecommendationService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Recommend": { + "timeout_millis": 5000, + "retry_codes_name": "unavailable", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_proto_list.json new file mode 100644 index 00000000000..c90e69baf40 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/discoveryengine/v1beta/common.proto", + "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client.ts new file mode 100644 index 00000000000..17490984ed2 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client.ts @@ -0,0 +1,1553 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/schema_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './schema_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for managing {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s. + * @class + * @memberof v1beta + */ +export class SchemaServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + schemaServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SchemaServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SchemaServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SchemaServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' + ), + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listSchemas: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'schemas') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{get: '/v1beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*}/operations',},{get: '/v1beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createSchemaResponse = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.Schema') as gax.protobuf.Type; + const createSchemaMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.CreateSchemaMetadata') as gax.protobuf.Type; + const updateSchemaResponse = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.Schema') as gax.protobuf.Type; + const updateSchemaMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.UpdateSchemaMetadata') as gax.protobuf.Type; + const deleteSchemaResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteSchemaMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.DeleteSchemaMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createSchema: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createSchemaResponse.decode.bind(createSchemaResponse), + createSchemaMetadata.decode.bind(createSchemaMetadata)), + updateSchema: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateSchemaResponse.decode.bind(updateSchemaResponse), + updateSchemaMetadata.decode.bind(updateSchemaMetadata)), + deleteSchema: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteSchemaResponse.decode.bind(deleteSchemaResponse), + deleteSchemaMetadata.decode.bind(deleteSchemaMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1beta.SchemaService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.schemaServiceStub) { + return this.schemaServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1beta.SchemaService. + this.schemaServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.SchemaService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1beta.SchemaService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const schemaServiceStubMethods = + ['getSchema', 'listSchemas', 'createSchema', 'updateSchema', 'deleteSchema']; + for (const methodName of schemaServiceStubMethods) { + const callPromise = this.schemaServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.schemaServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets a {@link google.cloud.discoveryengine.v1beta.Schema|Schema}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.Schema | Schema}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta/schema_service.get_schema.js + * region_tag:discoveryengine_v1beta_generated_SchemaService_GetSchema_async + */ + getSchema( + request?: protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.ISchema, + protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|undefined, {}|undefined + ]>; + getSchema( + request: protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.ISchema, + protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|null|undefined, + {}|null|undefined>): void; + getSchema( + request: protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.ISchema, + protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|null|undefined, + {}|null|undefined>): void; + getSchema( + request?: protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1beta.ISchema, + protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1beta.ISchema, + protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.ISchema, + protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getSchema(request, options, callback); + } + +/** + * Creates a {@link google.cloud.discoveryengine.v1beta.Schema|Schema}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {google.cloud.discoveryengine.v1beta.Schema} request.schema + * Required. The {@link google.cloud.discoveryengine.v1beta.Schema|Schema} to + * create. + * @param {string} request.schemaId + * Required. The ID to use for the + * {@link google.cloud.discoveryengine.v1beta.Schema|Schema}, which will become the + * final component of the + * {@link google.cloud.discoveryengine.v1beta.Schema.name|Schema.name}. + * + * This field should conform to + * [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length + * limit of 63 characters. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/schema_service.create_schema.js + * region_tag:discoveryengine_v1beta_generated_SchemaService_CreateSchema_async + */ + createSchema( + request?: protos.google.cloud.discoveryengine.v1beta.ICreateSchemaRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createSchema( + request: protos.google.cloud.discoveryengine.v1beta.ICreateSchemaRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createSchema( + request: protos.google.cloud.discoveryengine.v1beta.ICreateSchemaRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createSchema( + request?: protos.google.cloud.discoveryengine.v1beta.ICreateSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createSchema(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createSchema()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/schema_service.create_schema.js + * region_tag:discoveryengine_v1beta_generated_SchemaService_CreateSchema_async + */ + async checkCreateSchemaProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createSchema, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a {@link google.cloud.discoveryengine.v1beta.Schema|Schema}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.discoveryengine.v1beta.Schema} request.schema + * Required. The {@link google.cloud.discoveryengine.v1beta.Schema|Schema} to + * update. + * @param {boolean} request.allowMissing + * If set to true, and the + * {@link google.cloud.discoveryengine.v1beta.Schema|Schema} is not found, a new + * {@link google.cloud.discoveryengine.v1beta.Schema|Schema} will be created. In + * this situation, `update_mask` is ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/schema_service.update_schema.js + * region_tag:discoveryengine_v1beta_generated_SchemaService_UpdateSchema_async + */ + updateSchema( + request?: protos.google.cloud.discoveryengine.v1beta.IUpdateSchemaRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateSchema( + request: protos.google.cloud.discoveryengine.v1beta.IUpdateSchemaRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateSchema( + request: protos.google.cloud.discoveryengine.v1beta.IUpdateSchemaRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateSchema( + request?: protos.google.cloud.discoveryengine.v1beta.IUpdateSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'schema.name': request.schema!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateSchema(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateSchema()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/schema_service.update_schema.js + * region_tag:discoveryengine_v1beta_generated_SchemaService_UpdateSchema_async + */ + async checkUpdateSchemaProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateSchema, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a {@link google.cloud.discoveryengine.v1beta.Schema|Schema}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the schema, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/schema_service.delete_schema.js + * region_tag:discoveryengine_v1beta_generated_SchemaService_DeleteSchema_async + */ + deleteSchema( + request?: protos.google.cloud.discoveryengine.v1beta.IDeleteSchemaRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteSchema( + request: protos.google.cloud.discoveryengine.v1beta.IDeleteSchemaRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteSchema( + request: protos.google.cloud.discoveryengine.v1beta.IDeleteSchemaRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteSchema( + request?: protos.google.cloud.discoveryengine.v1beta.IDeleteSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteSchema(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteSchema()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/schema_service.delete_schema.js + * region_tag:discoveryengine_v1beta_generated_SchemaService_DeleteSchema_async + */ + async checkDeleteSchemaProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteSchema, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Gets a list of {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {number} request.pageSize + * The maximum number of {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s + * to return. The service may return fewer than this value. + * + * If unspecified, at most 100 + * {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s will be returned. + * + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} + * must match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link google.cloud.discoveryengine.v1beta.Schema | Schema}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSchemasAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listSchemas( + request?: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.ISchema[], + protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest|null, + protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse + ]>; + listSchemas( + request: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, + protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.ISchema>): void; + listSchemas( + request: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, + protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.ISchema>): void; + listSchemas( + request?: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, + protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.ISchema>, + callback?: PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, + protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.ISchema>): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.ISchema[], + protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest|null, + protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listSchemas(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {number} request.pageSize + * The maximum number of {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s + * to return. The service may return fewer than this value. + * + * If unspecified, at most 100 + * {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s will be returned. + * + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} + * must match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1beta.Schema | Schema} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSchemasAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listSchemasStream( + request?: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listSchemas']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSchemas.createStream( + this.innerApiCalls.listSchemas as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listSchemas`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent data store resource name, in the format of + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {number} request.pageSize + * The maximum number of {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s + * to return. The service may return fewer than this value. + * + * If unspecified, at most 100 + * {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s will be returned. + * + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} + * must match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.discoveryengine.v1beta.Schema | Schema}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1beta/schema_service.list_schemas.js + * region_tag:discoveryengine_v1beta_generated_SchemaService_ListSchemas_async + */ + listSchemasAsync( + request?: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listSchemas']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSchemas.asyncIterate( + this.innerApiCalls['listSchemas'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationDataStorePath(project:string,location:string,dataStore:string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.schemaServiceStub && !this._terminated) { + return this.schemaServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client_config.json new file mode 100644 index 00000000000..2c22818266f --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client_config.json @@ -0,0 +1,63 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.SchemaService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "GetSchema": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListSchemas": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "CreateSchema": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateSchema": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "DeleteSchema": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_proto_list.json new file mode 100644 index 00000000000..c90e69baf40 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/discoveryengine/v1beta/common.proto", + "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client.ts new file mode 100644 index 00000000000..41f95075218 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client.ts @@ -0,0 +1,1427 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for search. + * @class + * @memberof v1beta + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SearchServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}' + ), + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationCollectionDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}' + ), + projectLocationDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + search: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1beta.SearchService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1beta.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.SearchService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1beta.SearchService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const searchServiceStubMethods = + ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + + /** + * Performs a search. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The resource name of the Search serving config, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + * @param {string} request.query + * Raw search query. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}s + * to return. If unspecified, defaults to a reasonable value. The maximum + * allowed value is 100. Values above 100 will be coerced to 100. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {string} request.pageToken + * A page token received from a previous + * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.discoveryengine.v1beta.Document|Document}s deemed by the API + * as relevant) in search results. This field is only considered if + * {@link google.cloud.discoveryengine.v1beta.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. Filter + * expression is case-sensitive. + * + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * @param {string} request.orderBy + * The order in which documents are returned. Document can be ordered by + * a field in an {@link google.cloud.discoveryengine.v1beta.Document|Document} + * object. Leave it unset if ordered by relevance. OrderBy expression is + * case-sensitive. + * + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * @param {google.cloud.discoveryengine.v1beta.UserInfo} request.userInfo + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain documents. + * @param {number[]} request.params + * Additional search parameters. + * + * For public website search only, supported values are: + * + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.userPseudoId + * 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. + * + * This field should NOT have a fixed value such as `unknown_visitor`. + * + * This should be the same identifier as + * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} + * and + * {@link google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec} request.contentSearchSpec + * The content search spec that configs the desired behavior of content + * search. + * @param {boolean} request.safeSearch + * Whether to turn on safe search. This is only supported for + * {@link |ContentConfig.PUBLIC_WEBSITE}. + * @param {number[]} request.userLabels + * The user 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. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult | SearchResult}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult[], + protos.google.cloud.discoveryengine.v1beta.ISearchRequest|null, + protos.google.cloud.discoveryengine.v1beta.ISearchResponse + ]>; + search( + request: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.ISearchRequest, + protos.google.cloud.discoveryengine.v1beta.ISearchResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult>): void; + search( + request: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.ISearchRequest, + protos.google.cloud.discoveryengine.v1beta.ISearchResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult>): void; + search( + request?: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.ISearchRequest, + protos.google.cloud.discoveryengine.v1beta.ISearchResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult>, + callback?: PaginationCallback< + protos.google.cloud.discoveryengine.v1beta.ISearchRequest, + protos.google.cloud.discoveryengine.v1beta.ISearchResponse|null|undefined, + protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult>): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult[], + protos.google.cloud.discoveryengine.v1beta.ISearchRequest|null, + protos.google.cloud.discoveryengine.v1beta.ISearchResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'serving_config': request.servingConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The resource name of the Search serving config, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + * @param {string} request.query + * Raw search query. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}s + * to return. If unspecified, defaults to a reasonable value. The maximum + * allowed value is 100. Values above 100 will be coerced to 100. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {string} request.pageToken + * A page token received from a previous + * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.discoveryengine.v1beta.Document|Document}s deemed by the API + * as relevant) in search results. This field is only considered if + * {@link google.cloud.discoveryengine.v1beta.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. Filter + * expression is case-sensitive. + * + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * @param {string} request.orderBy + * The order in which documents are returned. Document can be ordered by + * a field in an {@link google.cloud.discoveryengine.v1beta.Document|Document} + * object. Leave it unset if ordered by relevance. OrderBy expression is + * case-sensitive. + * + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * @param {google.cloud.discoveryengine.v1beta.UserInfo} request.userInfo + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain documents. + * @param {number[]} request.params + * Additional search parameters. + * + * For public website search only, supported values are: + * + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.userPseudoId + * 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. + * + * This field should NOT have a fixed value such as `unknown_visitor`. + * + * This should be the same identifier as + * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} + * and + * {@link google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec} request.contentSearchSpec + * The content search spec that configs the desired behavior of content + * search. + * @param {boolean} request.safeSearch + * Whether to turn on safe search. This is only supported for + * {@link |ContentConfig.PUBLIC_WEBSITE}. + * @param {number[]} request.userLabels + * The user 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. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult | SearchResult} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'serving_config': request.servingConfig ?? '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `search`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The resource name of the Search serving config, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. + * This field is used to identify the serving configuration name, set + * of models used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. + * + * Use `default_branch` as the branch ID or leave this field empty, to search + * documents under the default branch. + * @param {string} request.query + * Raw search query. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}s + * to return. If unspecified, defaults to a reasonable value. The maximum + * allowed value is 100. Values above 100 will be coerced to 100. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {string} request.pageToken + * A page token received from a previous + * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * `INVALID_ARGUMENT` error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.discoveryengine.v1beta.Document|Document}s deemed by the API + * as relevant) in search results. This field is only considered if + * {@link google.cloud.discoveryengine.v1beta.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an `INVALID_ARGUMENT` is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the documents being filtered. Filter + * expression is case-sensitive. + * + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * @param {string} request.orderBy + * The order in which documents are returned. Document can be ordered by + * a field in an {@link google.cloud.discoveryengine.v1beta.Document|Document} + * object. Leave it unset if ordered by relevance. OrderBy expression is + * case-sensitive. + * + * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. + * @param {google.cloud.discoveryengine.v1beta.UserInfo} request.userInfo + * Information about the end user. + * Highly recommended for analytics. The user_agent string in UserInfo will + * be used to deduce device_type for analytics. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` + * error is returned. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain documents. + * @param {number[]} request.params + * Additional search parameters. + * + * For public website search only, supported values are: + * + * * `user_country_code`: string. Default empty. If set to non-empty, results + * are restricted or boosted based on the location provided. + * * `search_type`: double. Default empty. Enables non-webpage searching + * depending on the value. The only valid non-default value is 1, + * which enables image searching. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.userPseudoId + * 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. + * + * This field should NOT have a fixed value such as `unknown_visitor`. + * + * This should be the same identifier as + * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} + * and + * {@link google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec} request.contentSearchSpec + * The content search spec that configs the desired behavior of content + * search. + * @param {boolean} request.safeSearch + * Whether to turn on safe search. This is only supported for + * {@link |ContentConfig.PUBLIC_WEBSITE}. + * @param {number[]} request.userLabels + * The user 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. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult | SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1beta/search_service.search.js + * region_tag:discoveryengine_v1beta_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'serving_config': request.servingConfig ?? '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchPath(project:string,location:string,collection:string,dataStore:string,branch:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranch resource. + * + * @param {string} projectLocationCollectionDataStoreBranchName + * A fully-qualified path representing project_location_collection_data_store_branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).branch; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreServingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} serving_config + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreServingConfigPath(project:string,location:string,collection:string,dataStore:string,servingConfig:string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).data_store; + } + + /** + * Parse the serving_config from ProjectLocationCollectionDataStoreServingConfig resource. + * + * @param {string} projectLocationCollectionDataStoreServingConfigName + * A fully-qualified path representing project_location_collection_data_store_serving_config resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).serving_config; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchPath(project:string,location:string,dataStore:string,branch:string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranch resource. + * + * @param {string} projectLocationDataStoreBranchName + * A fully-qualified path representing project_location_data_store_branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { + return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).branch; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStoreServingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} serving_config + * @returns {string} Resource name string. + */ + projectLocationDataStoreServingConfigPath(project:string,location:string,dataStore:string,servingConfig:string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).data_store; + } + + /** + * Parse the serving_config from ProjectLocationDataStoreServingConfig resource. + * + * @param {string} projectLocationDataStoreServingConfigName + * A fully-qualified path representing project_location_data_store_serving_config resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { + return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).serving_config; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client_config.json new file mode 100644 index 00000000000..5efbd6c02f2 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client_config.json @@ -0,0 +1,43 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.SearchService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "unavailable", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_proto_list.json new file mode 100644 index 00000000000..c90e69baf40 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/discoveryengine/v1beta/common.proto", + "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client.ts new file mode 100644 index 00000000000..59c8780ebc4 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client.ts @@ -0,0 +1,1220 @@ +// Copyright 2023 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on a website to Discovery Engine API. + * @class + * @memberof v1beta + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new UserEventServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' + ), + projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' + ), + projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}' + ), + projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' + ), + projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{get: '/v1beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*}/operations',},{get: '/v1beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.ImportUserEventsResponse') as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.discoveryengine.v1beta.ImportUserEventsMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.discoveryengine.v1beta.UserEventService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.discoveryengine.v1beta.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.UserEventService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.discoveryengine.v1beta.UserEventService, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const userEventServiceStubMethods = + ['writeUserEvent', 'collectUserEvent', 'importUserEvents']; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'discoveryengine.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {google.cloud.discoveryengine.v1beta.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.UserEvent | UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta/user_event_service.write_user_event.js + * region_tag:discoveryengine_v1beta_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IUserEvent, + protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|undefined, {}|undefined + ]>; + writeUserEvent( + request: protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.IUserEvent, + protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request: protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.discoveryengine.v1beta.IUserEvent, + protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): void; + writeUserEvent( + request?: protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.discoveryengine.v1beta.IUserEvent, + protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.discoveryengine.v1beta.IUserEvent, + protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.discoveryengine.v1beta.IUserEvent, + protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } +/** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Discovery Engine API JavaScript pixel and + * Google Tag Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent DataStore resource name, such as + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * 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. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.api.HttpBody | HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta/user_event_service.collect_user_event.js + * region_tag:discoveryengine_v1beta_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest, + options?: CallOptions): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|undefined, {}|undefined + ]>; + collectUserEvent( + request: protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request: protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): void; + collectUserEvent( + request?: protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.api.IHttpBody, + protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + +/** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.discoveryengine.v1beta.ImportUserEventsRequest.InlineSource} request.inlineSource + * The Inline source for the input content for UserEvents. + * @param {google.cloud.discoveryengine.v1beta.GcsSource} request.gcsSource + * Cloud Storage location for the input content. + * @param {google.cloud.discoveryengine.v1beta.BigQuerySource} request.bigquerySource + * BigQuery input source. + * @param {string} request.parent + * Required. Parent DataStore resource name, of the form + * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` + * @param {google.cloud.discoveryengine.v1beta.ImportErrorConfig} request.errorConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/user_event_service.import_user_events.js + * region_tag:discoveryengine_v1beta_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.discoveryengine.v1beta.IImportUserEventsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importUserEvents( + request: protos.google.cloud.discoveryengine.v1beta.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request: protos.google.cloud.discoveryengine.v1beta.IImportUserEventsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importUserEvents( + request?: protos.google.cloud.discoveryengine.v1beta.IImportUserEventsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta/user_event_service.import_user_events.js + * region_tag:discoveryengine_v1beta_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importUserEvents, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified projectLocationCollectionDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStore resource. + * + * @param {string} projectLocationCollectionDataStoreName + * A fully-qualified path representing project_location_collection_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { + return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. + * + * @param {string} projectLocationCollectionDataStoreBranchDocumentName + * A fully-qualified path representing project_location_collection_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} collection + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + collection: collection, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; + } + + /** + * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; + } + + /** + * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. + * + * @param {string} projectLocationCollectionDataStoreSchemaName + * A fully-qualified path representing project_location_collection_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; + } + + /** + * Return a fully-qualified projectLocationDataStore resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @returns {string} Resource name string. + */ + projectLocationDataStorePath(project:string,location:string,dataStore:string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + }); + } + + /** + * Parse the project from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; + } + + /** + * Parse the location from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStore resource. + * + * @param {string} projectLocationDataStoreName + * A fully-qualified path representing project_location_data_store resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { + return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; + } + + /** + * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} branch + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + branch: branch, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; + } + + /** + * Parse the branch from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; + } + + /** + * Parse the document from ProjectLocationDataStoreBranchDocument resource. + * + * @param {string} projectLocationDataStoreBranchDocumentName + * A fully-qualified path representing project_location_data_store_branch_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { + return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDataStoreSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_store + * @param {string} schema + * @returns {string} Resource name string. + */ + projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ + project: project, + location: location, + data_store: dataStore, + schema: schema, + }); + } + + /** + * Parse the project from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; + } + + /** + * Parse the location from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; + } + + /** + * Parse the data_store from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the data_store. + */ + matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; + } + + /** + * Parse the schema from ProjectLocationDataStoreSchema resource. + * + * @param {string} projectLocationDataStoreSchemaName + * A fully-qualified path representing project_location_data_store_schema resource. + * @returns {string} A string representing the schema. + */ + matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { + return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client_config.json new file mode 100644 index 00000000000..556c7486730 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client_config.json @@ -0,0 +1,62 @@ +{ + "interfaces": { + "google.cloud.discoveryengine.v1beta.UserEventService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "CollectUserEvent": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ImportUserEvents": { + "timeout_millis": 300000, + "retry_codes_name": "unavailable", + "retry_params_name": "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_proto_list.json new file mode 100644 index 00000000000..c90e69baf40 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_proto_list.json @@ -0,0 +1,14 @@ +[ + "../../protos/google/cloud/discoveryengine/v1beta/common.proto", + "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document.proto", + "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", + "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", + "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", + "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" +] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..d40d5fb6af2 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.js @@ -0,0 +1,32 @@ +// Copyright 2023 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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const discoveryengine = require('@google-cloud/discoveryengine'); + +function main() { + const completionServiceClient = new discoveryengine.CompletionServiceClient(); + const documentServiceClient = new discoveryengine.DocumentServiceClient(); + const recommendationServiceClient = new discoveryengine.RecommendationServiceClient(); + const schemaServiceClient = new discoveryengine.SchemaServiceClient(); + const searchServiceClient = new discoveryengine.SearchServiceClient(); + const userEventServiceClient = new discoveryengine.UserEventServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..88a2bd48482 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,62 @@ +// Copyright 2023 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. ** + +import {CompletionServiceClient, DocumentServiceClient, RecommendationServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient} from '@google-cloud/discoveryengine'; + +// check that the client class type name can be used +function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { + client.close(); +} +function doStuffWithDocumentServiceClient(client: DocumentServiceClient) { + client.close(); +} +function doStuffWithRecommendationServiceClient(client: RecommendationServiceClient) { + client.close(); +} +function doStuffWithSchemaServiceClient(client: SchemaServiceClient) { + client.close(); +} +function doStuffWithSearchServiceClient(client: SearchServiceClient) { + client.close(); +} +function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const completionServiceClient = new CompletionServiceClient(); + doStuffWithCompletionServiceClient(completionServiceClient); + // check that the client instance can be created + const documentServiceClient = new DocumentServiceClient(); + doStuffWithDocumentServiceClient(documentServiceClient); + // check that the client instance can be created + const recommendationServiceClient = new RecommendationServiceClient(); + doStuffWithRecommendationServiceClient(recommendationServiceClient); + // check that the client instance can be created + const schemaServiceClient = new SchemaServiceClient(); + doStuffWithSchemaServiceClient(schemaServiceClient); + // check that the client instance can be created + const searchServiceClient = new SearchServiceClient(); + doStuffWithSearchServiceClient(searchServiceClient); + // check that the client instance can be created + const userEventServiceClient = new UserEventServiceClient(); + doStuffWithUserEventServiceClient(userEventServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/install.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 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. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_completion_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_completion_service_v1beta.ts new file mode 100644 index 00000000000..38dbbafcb0e --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_completion_service_v1beta.ts @@ -0,0 +1,609 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as completionserviceModule from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1beta.CompletionServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = completionserviceModule.v1beta.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = completionserviceModule.v1beta.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v1beta.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new completionserviceModule.v1beta.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CompleteQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CompleteQueryRequest', ['dataStore']); + request.dataStore = defaultValue1; + const expectedHeaderRequestParams = `data_store=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CompleteQueryResponse() + ); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CompleteQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CompleteQueryRequest', ['dataStore']); + request.dataStore = defaultValue1; + const expectedHeaderRequestParams = `data_store=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CompleteQueryResponse() + ); + client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery with error', async () => { + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CompleteQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CompleteQueryRequest', ['dataStore']); + request.dataStore = defaultValue1; + const expectedHeaderRequestParams = `data_store=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CompleteQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CompleteQueryRequest', ['dataStore']); + request.dataStore = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStore', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + }; + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStorePath', () => { + const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStore', () => { + const fakePath = "/rendered/path/projectLocationDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + }; + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStorePath', () => { + const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreName', () => { + const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreName', () => { + const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new completionserviceModule.v1beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_document_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_document_service_v1beta.ts new file mode 100644 index 00000000000..6b76fc7b39c --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_document_service_v1beta.ts @@ -0,0 +1,1824 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as documentserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta.DocumentServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = documentserviceModule.v1beta.DocumentServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = documentserviceModule.v1beta.DocumentServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = documentserviceModule.v1beta.DocumentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentServiceStub, undefined); + await client.initialize(); + assert(client.documentServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.documentServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getDocument', () => { + it('invokes getDocument without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocument without error using callback', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDocument( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocument with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocument with closed client', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDocument(request), expectedError); + }); + }); + + describe('createDocument', () => { + it('invokes createDocument without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocument without error using callback', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDocument( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocument with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocument with closed client', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDocument(request), expectedError); + }); + }); + + describe('updateDocument', () => { + it('invokes updateDocument without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest() + ); + request.document ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocument without error using callback', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest() + ); + request.document ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDocument( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocument with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest() + ); + request.document ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocument with closed client', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest() + ); + request.document ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDocument(request), expectedError); + }); + }); + + describe('deleteDocument', () => { + it('invokes deleteDocument without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocument without error using callback', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDocument( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocument with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocument with closed client', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDocument(request), expectedError); + }); + }); + + describe('importDocuments', () => { + it('invokes importDocuments without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importDocuments = stubLongRunningCall(expectedResponse); + const [operation] = await client.importDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importDocuments without error using callback', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importDocuments = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importDocuments( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importDocuments with call error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importDocuments with LRO error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportDocumentsProgress without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportDocumentsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportDocumentsProgress with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportDocumentsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('purgeDocuments', () => { + it('invokes purgeDocuments without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeDocuments = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeDocuments without error using callback', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeDocuments = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeDocuments( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeDocuments with call error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeDocuments with LRO error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeDocumentsProgress without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeDocumentsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeDocumentsProgress with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkPurgeDocumentsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listDocuments', () => { + it('invokes listDocuments without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCall(expectedResponse); + const [response] = await client.listDocuments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDocuments without error using callback', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDocuments( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IDocument[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDocuments with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDocumentsStream without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + ]; + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1beta.Document[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.Document) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); + assert( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listDocumentsStream with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1beta.Document[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.Document) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); + assert( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDocuments without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), + ]; + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.discoveryengine.v1beta.IDocument[] = []; + const iterable = client.listDocumentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDocuments with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDocumentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.discoveryengine.v1beta.IDocument[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStoreBranch', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + }; + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchPath', () => { + const result = client.projectLocationCollectionDataStoreBranchPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranch', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + }; + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchPath', () => { + const result = client.projectLocationDataStoreBranchPath("projectValue", "locationValue", "dataStoreValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new documentserviceModule.v1beta.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_recommendation_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_recommendation_service_v1beta.ts new file mode 100644 index 00000000000..35a785daf1a --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_recommendation_service_v1beta.ts @@ -0,0 +1,625 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as recommendationserviceModule from '../src'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1beta.RecommendationServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = recommendationserviceModule.v1beta.RecommendationServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = recommendationserviceModule.v1beta.RecommendationServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = recommendationserviceModule.v1beta.RecommendationServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recommendationServiceStub, undefined); + await client.initialize(); + assert(client.recommendationServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.recommendationServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.recommendationServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('recommend', () => { + it('invokes recommend without error', async () => { + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.RecommendRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.RecommendRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.RecommendResponse() + ); + client.innerApiCalls.recommend = stubSimpleCall(expectedResponse); + const [response] = await client.recommend(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.recommend as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.recommend as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recommend without error using callback', async () => { + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.RecommendRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.RecommendRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.RecommendResponse() + ); + client.innerApiCalls.recommend = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.recommend( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IRecommendResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.recommend as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.recommend as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recommend with error', async () => { + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.RecommendRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.RecommendRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.recommend = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.recommend(request), expectedError); + const actualRequest = (client.innerApiCalls.recommend as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.recommend as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes recommend with closed client', async () => { + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.RecommendRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.RecommendRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.recommend(request), expectedError); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreServingConfig', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreServingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + serving_config: "servingConfigValue", + }; + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreServingConfigPath', () => { + const result = client.projectLocationCollectionDataStoreServingConfigPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreServingConfig', () => { + const fakePath = "/rendered/path/projectLocationDataStoreServingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + serving_config: "servingConfigValue", + }; + const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreServingConfigPath', () => { + const result = client.projectLocationDataStoreServingConfigPath("projectValue", "locationValue", "dataStoreValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchProjectFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchLocationFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchServingConfigFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_schema_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_schema_service_v1beta.ts new file mode 100644 index 00000000000..35693b1a9f0 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_schema_service_v1beta.ts @@ -0,0 +1,1638 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as schemaserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta.SchemaServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = schemaserviceModule.v1beta.SchemaServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = schemaserviceModule.v1beta.SchemaServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = schemaserviceModule.v1beta.SchemaServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.schemaServiceStub, undefined); + await client.initialize(); + assert(client.schemaServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.schemaServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.schemaServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getSchema', () => { + it('invokes getSchema without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.GetSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.Schema() + ); + client.innerApiCalls.getSchema = stubSimpleCall(expectedResponse); + const [response] = await client.getSchema(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSchema without error using callback', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.GetSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.Schema() + ); + client.innerApiCalls.getSchema = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSchema( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.ISchema|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSchema with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.GetSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSchema = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSchema with closed client', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.GetSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getSchema(request), expectedError); + }); + }); + + describe('createSchema', () => { + it('invokes createSchema without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CreateSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createSchema = stubLongRunningCall(expectedResponse); + const [operation] = await client.createSchema(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSchema without error using callback', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CreateSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createSchema = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSchema( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSchema with call error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CreateSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSchema = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSchema with LRO error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CreateSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSchema = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createSchema(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateSchemaProgress without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateSchemaProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateSchemaProgress with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateSchemaProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateSchema', () => { + it('invokes updateSchema without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest() + ); + request.schema ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest', ['schema', 'name']); + request.schema.name = defaultValue1; + const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateSchema = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateSchema(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSchema without error using callback', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest() + ); + request.schema ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest', ['schema', 'name']); + request.schema.name = defaultValue1; + const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateSchema = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSchema( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSchema with call error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest() + ); + request.schema ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest', ['schema', 'name']); + request.schema.name = defaultValue1; + const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSchema = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSchema with LRO error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest() + ); + request.schema ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest', ['schema', 'name']); + request.schema.name = defaultValue1; + const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSchema = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateSchema(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateSchemaProgress without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateSchemaProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateSchemaProgress with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateSchemaProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteSchema', () => { + it('invokes deleteSchema without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteSchema = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteSchema(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchema without error using callback', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteSchema = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSchema( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchema with call error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSchema = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSchema with LRO error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSchema = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteSchema(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteSchemaProgress without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteSchemaProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteSchemaProgress with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteSchemaProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listSchemas', () => { + it('invokes listSchemas without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + ]; + client.innerApiCalls.listSchemas = stubSimpleCall(expectedResponse); + const [response] = await client.listSchemas(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchemas without error using callback', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + ]; + client.innerApiCalls.listSchemas = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSchemas( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.ISchema[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchemas with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSchemas = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listSchemas(request), expectedError); + const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSchemasStream without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + ]; + client.descriptors.page.listSchemas.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listSchemasStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1beta.Schema[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.Schema) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listSchemas.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSchemas, request)); + assert( + (client.descriptors.page.listSchemas.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listSchemasStream with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSchemas.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listSchemasStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1beta.Schema[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.Schema) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listSchemas.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSchemas, request)); + assert( + (client.descriptors.page.listSchemas.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSchemas without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), + ]; + client.descriptors.page.listSchemas.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.discoveryengine.v1beta.ISchema[] = []; + const iterable = client.listSchemasAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSchemas with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSchemas.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSchemasAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.discoveryengine.v1beta.ISchema[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSchemas.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStore', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + }; + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStorePath', () => { + const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStore', () => { + const fakePath = "/rendered/path/projectLocationDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + }; + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStorePath', () => { + const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreName', () => { + const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreName', () => { + const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new schemaserviceModule.v1beta.SchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_search_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_search_service_v1beta.ts new file mode 100644 index 00000000000..ba61eb9411d --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_search_service_v1beta.ts @@ -0,0 +1,925 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta.SearchServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = searchserviceModule.v1beta.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = searchserviceModule.v1beta.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v1beta.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v1beta.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + ]; + client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult[] = []; + stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.search.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.search, request)); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), + ]; + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult[] = []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.SearchRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStoreBranch', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + }; + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchPath', () => { + const result = client.projectLocationCollectionDataStoreBranchPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreServingConfig', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreServingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + serving_config: "servingConfigValue", + }; + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreServingConfigPath', () => { + const result = client.projectLocationCollectionDataStoreServingConfigPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName', () => { + const result = client.matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranch', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranch"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + }; + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchPath', () => { + const result = client.projectLocationDataStoreBranchPath("projectValue", "locationValue", "dataStoreValue", "branchValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreServingConfig', () => { + const fakePath = "/rendered/path/projectLocationDataStoreServingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + serving_config: "servingConfigValue", + }; + const client = new searchserviceModule.v1beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreServingConfigPath', () => { + const result = client.projectLocationDataStoreServingConfigPath("projectValue", "locationValue", "dataStoreValue", "servingConfigValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchProjectFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchLocationFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchServingConfigFromProjectLocationDataStoreServingConfigName', () => { + const result = client.matchServingConfigFromProjectLocationDataStoreServingConfigName(fakePath); + assert.strictEqual(result, "servingConfigValue"); + assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_user_event_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_user_event_service_v1beta.ts new file mode 100644 index 00000000000..09d4aec93b1 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_user_event_service_v1beta.ts @@ -0,0 +1,1162 @@ +// Copyright 2023 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as usereventserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta.UserEventServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = usereventserviceModule.v1beta.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = usereventserviceModule.v1beta.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v1beta.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.WriteUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.UserEvent() + ); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.WriteUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.UserEvent() + ); + client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IUserEvent|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.WriteUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.WriteUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CollectUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CollectUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CollectUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.CollectUserEventRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('projectLocationCollectionDataStore', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + }; + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStorePath', () => { + const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreBranchDocumentPath', () => { + const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationCollectionDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + collection: "collectionValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationCollectionDataStoreSchemaPath', () => { + const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStore', () => { + const fakePath = "/rendered/path/projectLocationDataStore"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + }; + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStorePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStorePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStorePath', () => { + const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreName', () => { + const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreName', () => { + const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreBranchDocument', () => { + const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + branch: "branchValue", + document: "documentValue", + }; + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreBranchDocumentPath', () => { + const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "branchValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDataStoreSchema', () => { + const fakePath = "/rendered/path/projectLocationDataStoreSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + data_store: "dataStoreValue", + schema: "schemaValue", + }; + const client = new usereventserviceModule.v1beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDataStoreSchemaPath', () => { + const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "dataStoreValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { + const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); + assert.strictEqual(result, "schemaValue"); + assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/tsconfig.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/webpack.config.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/webpack.config.js new file mode 100644 index 00000000000..eb56fa1d866 --- /dev/null +++ b/owl-bot-staging/google-cloud-discoveryengine/v1beta/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'CompletionService', + filename: './completion-service.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From 95fd07035ab423a8f101a0ebafa4f3f8d278e228 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Sat, 17 Jun 2023 00:12:09 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../v1/.eslintignore | 7 - .../v1/.eslintrc.json | 3 - .../v1/.gitignore | 14 - .../google-cloud-discoveryengine/v1/.jsdoc.js | 55 - .../v1/.mocharc.js | 33 - .../v1/.prettierrc.js | 22 - .../google-cloud-discoveryengine/v1/README.md | 1 - .../v1/linkinator.config.json | 16 - .../v1/package.json | 68 - .../cloud/discoveryengine/v1/common.proto | 100 - .../v1/completion_service.proto | 116 -- .../cloud/discoveryengine/v1/document.proto | 118 -- .../discoveryengine/v1/document_service.proto | 313 --- .../discoveryengine/v1/import_config.proto | 334 --- .../discoveryengine/v1/purge_config.proto | 86 - .../cloud/discoveryengine/v1/schema.proto | 58 - .../discoveryengine/v1/schema_service.proto | 256 --- .../discoveryengine/v1/search_service.proto | 289 --- .../cloud/discoveryengine/v1/user_event.proto | 458 ---- .../v1/user_event_service.proto | 133 -- .../v1/completion_service.complete_query.js | 99 - .../v1/document_service.create_document.js | 86 - .../v1/document_service.delete_document.js | 68 - .../v1/document_service.get_document.js | 68 - .../v1/document_service.import_documents.js | 133 -- .../v1/document_service.list_documents.js | 88 - .../v1/document_service.purge_documents.js | 75 - .../v1/document_service.update_document.js | 74 - .../v1/schema_service.create_schema.js | 79 - .../v1/schema_service.delete_schema.js | 63 - .../generated/v1/schema_service.get_schema.js | 62 - .../v1/schema_service.list_schemas.js | 81 - .../v1/schema_service.update_schema.js | 68 - .../generated/v1/search_service.search.js | 172 -- ...adata.google.cloud.discoveryengine.v1.json | 867 -------- .../user_event_service.collect_user_event.js | 81 - .../user_event_service.import_user_events.js | 83 - .../v1/user_event_service.write_user_event.js | 67 - .../v1/src/index.ts | 33 - .../v1/src/v1/completion_service_client.ts | 854 -------- .../v1/completion_service_client_config.json | 43 - .../src/v1/completion_service_proto_list.json | 13 - .../v1/src/v1/document_service_client.ts | 1839 ---------------- .../v1/document_service_client_config.json | 82 - .../src/v1/document_service_proto_list.json | 13 - .../v1/src/v1/gapic_metadata.json | 261 --- .../v1/src/v1/index.ts | 23 - .../v1/src/v1/schema_service_client.ts | 1550 -------------- .../src/v1/schema_service_client_config.json | 63 - .../v1/src/v1/schema_service_proto_list.json | 13 - .../v1/src/v1/search_service_client.ts | 1367 ------------ .../src/v1/search_service_client_config.json | 43 - .../v1/src/v1/search_service_proto_list.json | 13 - .../v1/src/v1/user_event_service_client.ts | 1220 ----------- .../v1/user_event_service_client_config.json | 62 - .../src/v1/user_event_service_proto_list.json | 13 - .../system-test/fixtures/sample/src/index.js | 31 - .../system-test/fixtures/sample/src/index.ts | 56 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_completion_service_v1.ts | 609 ------ .../v1/test/gapic_document_service_v1.ts | 1824 ---------------- .../v1/test/gapic_schema_service_v1.ts | 1638 --------------- .../v1/test/gapic_search_service_v1.ts | 925 --------- .../v1/test/gapic_user_event_service_v1.ts | 1162 ----------- .../v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1beta/.eslintignore | 7 - .../v1beta/.eslintrc.json | 3 - .../v1beta/.gitignore | 14 - .../v1beta/.jsdoc.js | 55 - .../v1beta/.mocharc.js | 33 - .../v1beta/.prettierrc.js | 22 - .../v1beta/README.md | 1 - .../v1beta/linkinator.config.json | 16 - .../v1beta/package.json | 69 - .../cloud/discoveryengine/v1beta/common.proto | 129 -- .../v1beta/completion_service.proto | 118 -- .../discoveryengine/v1beta/document.proto | 123 -- .../v1beta/document_service.proto | 316 --- .../v1beta/import_config.proto | 342 --- .../discoveryengine/v1beta/purge_config.proto | 86 - .../v1beta/recommendation_service.proto | 206 -- .../cloud/discoveryengine/v1beta/schema.proto | 58 - .../v1beta/schema_service.proto | 259 --- .../v1beta/search_service.proto | 617 ------ .../discoveryengine/v1beta/user_event.proto | 465 ----- .../v1beta/user_event_service.proto | 133 -- .../completion_service.complete_query.js | 101 - .../document_service.create_document.js | 86 - .../document_service.delete_document.js | 68 - .../v1beta/document_service.get_document.js | 68 - .../document_service.import_documents.js | 136 -- .../v1beta/document_service.list_documents.js | 88 - .../document_service.purge_documents.js | 75 - .../document_service.update_document.js | 75 - .../recommendation_service.recommend.js | 157 -- .../v1beta/schema_service.create_schema.js | 80 - .../v1beta/schema_service.delete_schema.js | 63 - .../v1beta/schema_service.get_schema.js | 62 - .../v1beta/schema_service.list_schemas.js | 81 - .../v1beta/schema_service.update_schema.js | 70 - .../generated/v1beta/search_service.search.js | 197 -- ...a.google.cloud.discoveryengine.v1beta.json | 947 --------- .../user_event_service.collect_user_event.js | 81 - .../user_event_service.import_user_events.js | 80 - .../user_event_service.write_user_event.js | 67 - .../v1beta/src/index.ts | 35 - .../src/v1beta/completion_service_client.ts | 856 -------- .../completion_service_client_config.json | 43 - .../v1beta/completion_service_proto_list.json | 14 - .../src/v1beta/document_service_client.ts | 1845 ----------------- .../document_service_client_config.json | 82 - .../v1beta/document_service_proto_list.json | 14 - .../v1beta/src/v1beta/gapic_metadata.json | 285 --- .../v1beta/src/v1beta/index.ts | 24 - .../v1beta/recommendation_service_client.ts | 937 --------- .../recommendation_service_client_config.json | 43 - .../recommendation_service_proto_list.json | 14 - .../src/v1beta/schema_service_client.ts | 1553 -------------- .../v1beta/schema_service_client_config.json | 63 - .../src/v1beta/schema_service_proto_list.json | 14 - .../src/v1beta/search_service_client.ts | 1427 ------------- .../v1beta/search_service_client_config.json | 43 - .../src/v1beta/search_service_proto_list.json | 14 - .../src/v1beta/user_event_service_client.ts | 1220 ----------- .../user_event_service_client_config.json | 62 - .../v1beta/user_event_service_proto_list.json | 14 - .../system-test/fixtures/sample/src/index.js | 32 - .../system-test/fixtures/sample/src/index.ts | 62 - .../v1beta/system-test/install.ts | 49 - .../test/gapic_completion_service_v1beta.ts | 609 ------ .../test/gapic_document_service_v1beta.ts | 1824 ---------------- .../gapic_recommendation_service_v1beta.ts | 625 ------ .../test/gapic_schema_service_v1beta.ts | 1638 --------------- .../test/gapic_search_service_v1beta.ts | 925 --------- .../test/gapic_user_event_service_v1beta.ts | 1162 ----------- .../v1beta/tsconfig.json | 19 - .../v1beta/webpack.config.js | 64 - .../v1beta/completion_service.proto | 2 + .../discoveryengine/v1beta/document.proto | 5 +- .../v1beta/import_config.proto | 20 +- .../v1beta/search_service.proto | 46 + .../protos/protos.d.ts | 115 + .../protos/protos.js | 278 +++ .../protos/protos.json | 35 +- .../completion_service.complete_query.js | 2 + .../document_service.import_documents.js | 2 +- ...a.google.cloud.discoveryengine.v1beta.json | 4 +- .../user_event_service.import_user_events.js | 11 +- .../src/v1beta/completion_service_client.ts | 2 + .../src/v1beta/document_service_client.ts | 2 +- .../src/v1beta/user_event_service_client.ts | 6 +- 152 files changed, 495 insertions(+), 39976 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/common.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/completion_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/import_config.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/purge_config.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/search_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/completion_service.complete_query.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.create_document.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.delete_document.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.get_document.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.import_documents.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.list_documents.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.purge_documents.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.update_document.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.create_schema.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.delete_schema.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.get_schema.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.list_schemas.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.update_schema.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/search_service.search.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/snippet_metadata.google.cloud.discoveryengine.v1.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_completion_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_document_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_schema_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_search_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_user_event_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.gitignore delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/README.md delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/package.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/common.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/completion_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/import_config.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/purge_config.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/search_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event_service.proto delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/completion_service.complete_query.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.create_document.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.delete_document.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.get_document.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.import_documents.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.list_documents.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.purge_documents.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.update_document.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/recommendation_service.recommend.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.create_schema.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.delete_schema.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.get_schema.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.list_schemas.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.update_schema.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/search_service.search.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/index.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_completion_service_v1beta.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_document_service_v1beta.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_recommendation_service_v1beta.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_schema_service_v1beta.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_search_service_v1beta.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_user_event_service_v1beta.ts delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-discoveryengine/v1beta/webpack.config.js diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintignore b/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintrc.json b/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.gitignore b/owl-bot-staging/google-cloud-discoveryengine/v1/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.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__ diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.jsdoc.js b/owl-bot-staging/google-cloud-discoveryengine/v1/.jsdoc.js deleted file mode 100644 index 69c2c79afc4..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 2023 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/discoveryengine', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.mocharc.js b/owl-bot-staging/google-cloud-discoveryengine/v1/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 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. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -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 diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/.prettierrc.js b/owl-bot-staging/google-cloud-discoveryengine/v1/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 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. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/README.md b/owl-bot-staging/google-cloud-discoveryengine/v1/README.md deleted file mode 100644 index 3f2b1b5b595..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Discoveryengine: Nodejs Client diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/linkinator.config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/package.json b/owl-bot-staging/google-cloud-discoveryengine/v1/package.json deleted file mode 100644 index 63ead994003..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@google-cloud/discoveryengine", - "version": "0.1.0", - "description": "Discoveryengine client for Node.js", - "repository": "googleapis/nodejs-discoveryengine", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google discoveryengine", - "discoveryengine", - "completion service", - "document service", - "schema service", - "search service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/common.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/common.proto deleted file mode 100644 index b6f887c33cd..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/common.proto +++ /dev/null @@ -1,100 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; -option (google.api.resource_definition) = { - type: "discoveryengine.googleapis.com/Branch" - pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}" - pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}" -}; -option (google.api.resource_definition) = { - type: "discoveryengine.googleapis.com/DataStore" - pattern: "projects/{project}/locations/{location}/dataStores/{data_store}" - pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}" -}; -option (google.api.resource_definition) = { - type: "discoveryengine.googleapis.com/ServingConfig" - pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}" - pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}" -}; - -// A custom attribute that is not explicitly modeled in a resource, e.g. -// [UserEvent][google.cloud.discoveryengine.v1.UserEvent]. -message CustomAttribute { - // The textual values of this custom attribute. For example, `["yellow", - // "green"]` when the key is "color". - // - // Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is - // returned. - // - // Exactly one of - // [CustomAttribute.text][google.cloud.discoveryengine.v1.CustomAttribute.text] - // or - // [CustomAttribute.numbers][google.cloud.discoveryengine.v1.CustomAttribute.numbers] - // should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. - repeated string text = 1; - - // The numerical values of this custom attribute. For example, `[2.3, 15.4]` - // when the key is "lengths_cm". - // - // Exactly one of - // [CustomAttribute.text][google.cloud.discoveryengine.v1.CustomAttribute.text] - // or - // [CustomAttribute.numbers][google.cloud.discoveryengine.v1.CustomAttribute.numbers] - // should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. - repeated double numbers = 2; -} - -// Information of an end user. -message UserInfo { - // Highly recommended for logged-in users. Unique identifier for logged-in - // user, such as a user name. Don't set for anonymous users. - // - // Always use a hashed value for this ID. - // - // Don't set the field to the same fixed ID for different users. This mixes - // the event history of those users together, which results in degraded - // model quality. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - string user_id = 1; - - // User agent as included in the HTTP header. Required for getting - // [SearchResponse.sponsored_results][]. - // - // The field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - // - // This should not be set when using the client side event reporting with - // GTM or JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1.UserEventService.CollectUserEvent] - // or if - // [UserEvent.direct_user_request][google.cloud.discoveryengine.v1.UserEvent.direct_user_request] - // is set. - string user_agent = 2; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/completion_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/completion_service.proto deleted file mode 100644 index 29ba6317dc1..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/completion_service.proto +++ /dev/null @@ -1,116 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "CompletionServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; - -// Service for Auto-Completion. -service CompletionService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Completes the specified user input with keyword suggestions. - rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { - option (google.api.http) = { - get: "/v1/{data_store=projects/*/locations/*/dataStores/*}:completeQuery" - additional_bindings { - get: "/v1/{data_store=projects/*/locations/*/collections/*/dataStores/*}:completeQuery" - } - }; - } -} - -// Request message for -// [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1.CompletionService.CompleteQuery] -// method. -message CompleteQueryRequest { - // Required. The parent data store resource name for which the completion is - // performed, such as - // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`. - string data_store = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // Required. The typeahead input used to fetch suggestions. Maximum length is - // 128 characters. - string query = 2 [(google.api.field_behavior) = REQUIRED]; - - // Selects data model of query suggestions for serving. Currently supported - // values: - // - // * `document` - Using suggestions generated from user-imported documents. - // * `search-history` - Using suggestions generated from the past history of - // [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] - // API calls. Do not use it when there is no traffic for Search API. - // * `user-event` - Using suggestions generated from user-imported search - // events. - // - // Default values: - // - // * `document` is the default model for regular dataStores. - // * `search-history` is the default model for - // [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1.IndustryVertical.SITE_SEARCH] - // dataStores. - string query_model = 3; - - // 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. - // - // This field should NOT have a fixed value such as `unknown_visitor`. - // - // This should be the same identifier as - // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id] - // and - // [SearchRequest.user_pseudo_id][google.cloud.discoveryengine.v1.SearchRequest.user_pseudo_id]. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - string user_pseudo_id = 4; -} - -// Response message for -// [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1.CompletionService.CompleteQuery] -// method. -message CompleteQueryResponse { - // Suggestions as search queries. - message QuerySuggestion { - // The suggestion for the query. - string suggestion = 1; - } - - // Results of the matched query suggestions. The result list is ordered and - // the first result is a top suggestion. - repeated QuerySuggestion query_suggestions = 1; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document.proto deleted file mode 100644 index 2935f206b8b..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document.proto +++ /dev/null @@ -1,118 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "DocumentProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; - -// Document captures all raw metadata information of items to be recommended or -// searched. -message Document { - option (google.api.resource) = { - type: "discoveryengine.googleapis.com/Document" - pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}" - pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}" - }; - - // Unstructured data linked to this document. - message Content { - oneof content { - // The content represented as a stream of bytes. The maximum length is - // 1,000,000 bytes (1 MB / ~0.95 MiB). - // - // Note: As with all `bytes` fields, this field is represented as pure - // binary in Protocol Buffers and base64-encoded string in JSON. For - // example, `abc123!?$*&()'-=@~` should be represented as - // `YWJjMTIzIT8kKiYoKSctPUB+` in JSON. See - // https://developers.google.com/protocol-buffers/docs/proto3#json. - bytes raw_bytes = 2; - - // The URI of the content. Only Cloud Storage URIs (e.g. - // `gs://bucket-name/path/to/file`) are supported. The maximum file size - // is 100 MB. - string uri = 3; - } - - // The MIME type of the content. Supported types: - // - // * `application/pdf` (PDF) - // * `text/html` (HTML) - // - // See https://www.iana.org/assignments/media-types/media-types.xhtml. - string mime_type = 1; - } - - // Data representation. One of - // [struct_data][google.cloud.discoveryengine.v1.Document.struct_data] or - // [json_data][google.cloud.discoveryengine.v1.Document.json_data] should be - // provided otherwise an `INVALID_ARGUMENT` error is thrown. - oneof data { - // The structured JSON data for the document. It should conform to the - // registered [Schema.schema][google.cloud.discoveryengine.v1.Schema.schema] - // or an `INVALID_ARGUMENT` error is thrown. - google.protobuf.Struct struct_data = 4; - - // The JSON string representation of the document. It should conform to the - // registered [Schema.schema][google.cloud.discoveryengine.v1.Schema.schema] - // or an `INVALID_ARGUMENT` error is thrown. - string json_data = 5; - } - - // Immutable. The full resource name of the document. - // Format: - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document_id}`. - // - // This field must be a UTF-8 encoded string with a length limit of 1024 - // characters. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The identifier of the document. - // - // Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) - // standard with a length limit of 63 characters. - string id = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // The identifier of the schema located in the same data store. - string schema_id = 3; - - // The unstructured data linked to this document. Content must be set if this - // document is under a - // `CONTENT_REQUIRED` data store. - Content content = 10; - - // The identifier of the parent document. Currently supports at most two level - // document hierarchy. - // - // Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) - // standard with a length limit of 63 characters. - string parent_document_id = 7; - - // Output only. This field is OUTPUT_ONLY. - // It contains derived data that are not in the original input document. - google.protobuf.Struct derived_struct_data = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document_service.proto deleted file mode 100644 index b46cd918f4c..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/document_service.proto +++ /dev/null @@ -1,313 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1/document.proto"; -import "google/cloud/discoveryengine/v1/import_config.proto"; -import "google/cloud/discoveryengine/v1/purge_config.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "DocumentServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; - -// Service for ingesting [Document][google.cloud.discoveryengine.v1.Document] -// information of the customer's website. -service DocumentService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Gets a [Document][google.cloud.discoveryengine.v1.Document]. - rpc GetDocument(GetDocumentRequest) returns (Document) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" - additional_bindings { - get: "/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s. - rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents" - additional_bindings { - get: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a [Document][google.cloud.discoveryengine.v1.Document]. - rpc CreateDocument(CreateDocumentRequest) returns (Document) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents" - body: "document" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents" - body: "document" - } - }; - option (google.api.method_signature) = "parent,document,document_id"; - } - - // Updates a [Document][google.cloud.discoveryengine.v1.Document]. - rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { - option (google.api.http) = { - patch: "/v1/{document.name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" - body: "document" - additional_bindings { - patch: "/v1/{document.name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" - body: "document" - } - }; - } - - // Deletes a [Document][google.cloud.discoveryengine.v1.Document]. - rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" - additional_bindings { - delete: "/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Bulk import of multiple - // [Document][google.cloud.discoveryengine.v1.Document]s. Request processing - // may be synchronous. Non-existing items will be created. - // - // Note: It is possible for a subset of the - // [Document][google.cloud.discoveryengine.v1.Document]s to be successfully - // updated. - rpc ImportDocuments(ImportDocumentsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:import" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:import" - body: "*" - } - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.discoveryengine.v1.ImportDocumentsResponse" - metadata_type: "google.cloud.discoveryengine.v1.ImportDocumentsMetadata" - }; - } - - // Permanently deletes all selected - // [Document][google.cloud.discoveryengine.v1.Document]s in a branch. - // - // This process is asynchronous. Depending on the number of - // [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this - // operation can take hours to complete. Before the delete operation - // completes, some [Document][google.cloud.discoveryengine.v1.Document]s might - // still be returned by - // [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] - // or - // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments]. - // - // To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s - // to be deleted, set - // [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force] - // to false. - rpc PurgeDocuments(PurgeDocumentsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:purge" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:purge" - body: "*" - } - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.discoveryengine.v1.PurgeDocumentsResponse" - metadata_type: "google.cloud.discoveryengine.v1.PurgeDocumentsMetadata" - }; - } -} - -// Request message for -// [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] -// method. -message GetDocumentRequest { - // Required. Full resource name of - // [Document][google.cloud.discoveryengine.v1.Document], such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - // - // If the caller does not have permission to access the - // [Document][google.cloud.discoveryengine.v1.Document], regardless of whether - // or not it exists, a `PERMISSION_DENIED` error is returned. - // - // If the requested [Document][google.cloud.discoveryengine.v1.Document] does - // not exist, a `NOT_FOUND` error is returned. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Document" - } - ]; -} - -// Request message for -// [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments] -// method. -message ListDocumentsRequest { - // Required. The parent branch resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - // Use `default_branch` as the branch ID, to list documents under the default - // branch. - // - // If the caller does not have permission to list [Documents][]s under this - // branch, regardless of whether or not this branch exists, a - // `PERMISSION_DENIED` error is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Branch" - } - ]; - - // Maximum number of [Document][google.cloud.discoveryengine.v1.Document]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. - int32 page_size = 2; - - // A page token - // [ListDocumentsResponse.next_page_token][google.cloud.discoveryengine.v1.ListDocumentsResponse.next_page_token], - // received from a previous - // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments] - // must match the call that provided the page token. Otherwise, an - // `INVALID_ARGUMENT` error is returned. - string page_token = 3; -} - -// Response message for -// [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments] -// method. -message ListDocumentsResponse { - // The [Document][google.cloud.discoveryengine.v1.Document]s. - repeated Document documents = 1; - - // A token that can be sent as - // [ListDocumentsRequest.page_token][google.cloud.discoveryengine.v1.ListDocumentsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request message for -// [DocumentService.CreateDocument][google.cloud.discoveryengine.v1.DocumentService.CreateDocument] -// method. -message CreateDocumentRequest { - // Required. The parent resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Branch" - } - ]; - - // Required. The [Document][google.cloud.discoveryengine.v1.Document] to - // create. - Document document = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the - // [Document][google.cloud.discoveryengine.v1.Document], which will become the - // final component of the - // [Document.name][google.cloud.discoveryengine.v1.Document.name]. - // - // If the caller does not have permission to create the - // [Document][google.cloud.discoveryengine.v1.Document], regardless of whether - // or not it exists, a `PERMISSION_DENIED` error is returned. - // - // This field must be unique among all - // [Document][google.cloud.discoveryengine.v1.Document]s with the same - // [parent][google.cloud.discoveryengine.v1.CreateDocumentRequest.parent]. - // Otherwise, an `ALREADY_EXISTS` error is returned. - // - // This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) - // standard with a length limit of 63 characters. Otherwise, an - // `INVALID_ARGUMENT` error is returned. - string document_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for -// [DocumentService.UpdateDocument][google.cloud.discoveryengine.v1.DocumentService.UpdateDocument] -// method. -message UpdateDocumentRequest { - // Required. The document to update/create. - // - // If the caller does not have permission to update the - // [Document][google.cloud.discoveryengine.v1.Document], regardless of whether - // or not it exists, a `PERMISSION_DENIED` error is returned. - // - // If the [Document][google.cloud.discoveryengine.v1.Document] to update does - // not exist and - // [allow_missing][google.cloud.discoveryengine.v1.UpdateDocumentRequest.allow_missing] - // is not set, a `NOT_FOUND` error is returned. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // If set to true, and the - // [Document][google.cloud.discoveryengine.v1.Document] is not found, a new - // [Document][google.cloud.discoveryengine.v1.Document] will be created. - bool allow_missing = 2; -} - -// Request message for -// [DocumentService.DeleteDocument][google.cloud.discoveryengine.v1.DocumentService.DeleteDocument] -// method. -message DeleteDocumentRequest { - // Required. Full resource name of - // [Document][google.cloud.discoveryengine.v1.Document], such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - // - // If the caller does not have permission to delete the - // [Document][google.cloud.discoveryengine.v1.Document], regardless of whether - // or not it exists, a `PERMISSION_DENIED` error is returned. - // - // If the [Document][google.cloud.discoveryengine.v1.Document] to delete does - // not exist, a `NOT_FOUND` error is returned. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Document" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/import_config.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/import_config.proto deleted file mode 100644 index 4680ebafde2..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/import_config.proto +++ /dev/null @@ -1,334 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1/document.proto"; -import "google/cloud/discoveryengine/v1/user_event.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/date.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "ImportConfigProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; - -// Cloud Storage location for input content. -message GcsSource { - // Required. Cloud Storage URIs to input files. URI can be up to - // 2000 characters long. URIs can match the full object path (for example, - // `gs://bucket/directory/object.json`) or a pattern matching one or more - // files, such as `gs://bucket/directory/*.json`. - // - // A request can contain at most 100 files (or 100,000 files if `data_schema` - // is `content`). Each file can be up to 2 GB (or 100 MB if `data_schema` is - // `content`). - repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; - - // The schema to use when parsing the data from the source. - // - // Supported values for document imports: - // - // * `document` (default): One JSON - // [Document][google.cloud.discoveryengine.v1.Document] per line. Each - // document must - // have a valid [Document.id][google.cloud.discoveryengine.v1.Document.id]. - // * `content`: Unstructured data (e.g. PDF, HTML). Each file matched by - // `input_uris` will become a document, with the ID set to the first 128 - // bits of SHA256(URI) encoded as a hex string. - // * `custom`: One custom data JSON per row in arbitrary format that conforms - // the defined [Schema][google.cloud.discoveryengine.v1.Schema] of the data - // store. This can only be used by the GENERIC Data Store vertical. - // - // Supported values for user even imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.discoveryengine.v1.UserEvent] per line. - string data_schema = 2; -} - -// BigQuery source import data from. -message BigQuerySource { - // BigQuery table partition info. Leave this empty if the BigQuery table - // is not partitioned. - oneof partition { - // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. - google.type.Date partition_date = 5; - } - - // The project ID (can be project # or ID) that the BigQuery source is in with - // a length limit of 128 characters. If not specified, inherits the project - // ID from the parent request. - string project_id = 1; - - // Required. The BigQuery data set to copy the data from with a length limit - // of 1,024 characters. - string dataset_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The BigQuery table to copy the data from with a length limit of - // 1,024 characters. - string table_id = 3 [(google.api.field_behavior) = REQUIRED]; - - // Intermediate Cloud Storage directory used for the import with a length - // limit of 2,000 characters. Can be specified if one wants to have the - // BigQuery export to a specific Cloud Storage directory. - string gcs_staging_dir = 4; - - // The schema to use when parsing the data from the source. - // - // Supported values for user event imports: - // - // * `user_event` (default): One - // [UserEvent][google.cloud.discoveryengine.v1.UserEvent] per row. - // - // Supported values for document imports: - // - // * `document` (default): One - // [Document][google.cloud.discoveryengine.v1.Document] format per - // row. Each document must have a valid - // [Document.id][google.cloud.discoveryengine.v1.Document.id] and one of - // [Document.json_data][google.cloud.discoveryengine.v1.Document.json_data] - // or - // [Document.struct_data][google.cloud.discoveryengine.v1.Document.struct_data]. - // * `custom`: One custom data per row in arbitrary format that conforms the - // defined [Schema][google.cloud.discoveryengine.v1.Schema] of the data - // store. This can only be used by the GENERIC Data Store vertical. - string data_schema = 6; -} - -// Configuration of destination for Import related errors. -message ImportErrorConfig { - // Required. Errors destination. - oneof destination { - // Cloud Storage prefix for import errors. This must be an empty, - // existing Cloud Storage directory. Import errors will be written to - // sharded files in this directory, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Request message for the ImportUserEvents request. -message ImportUserEventsRequest { - // The inline source for the input config for ImportUserEvents method. - message InlineSource { - // Required. A list of user events to import. Recommended max of 10k items. - repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // The desired input source of the user event data. - oneof source { - // Required. The Inline source for the input content for UserEvents. - InlineSource inline_source = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Cloud Storage location for the input content. - GcsSource gcs_source = 3 [(google.api.field_behavior) = REQUIRED]; - - // Required. BigQuery input source. - BigQuerySource bigquery_source = 4 [(google.api.field_behavior) = REQUIRED]; - } - - // Required. Parent DataStore resource name, of the form - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // The desired location of errors incurred during the Import. Cannot be set - // for inline user event imports. - ImportErrorConfig error_config = 5; -} - -// Response of the ImportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ImportErrorConfig error_config = 2; - - // Count of user events imported with complete existing Documents. - int64 joined_events_count = 3; - - // Count of user events imported, but with Document information not found - // in the existing Branch. - int64 unjoined_events_count = 4; -} - -// Metadata related to the progress of the Import operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ImportUserEventsMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were processed successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; -} - -// Metadata related to the progress of the ImportDocuments operation. This will -// be returned by the google.longrunning.Operation.metadata field. -message ImportDocumentsMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were processed successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; -} - -// Request message for Import methods. -message ImportDocumentsRequest { - // The inline source for the input config for ImportDocuments method. - message InlineSource { - // Required. A list of documents to update/create. Each document must have a - // valid [Document.id][google.cloud.discoveryengine.v1.Document.id]. - // Recommended max of 100 items. - repeated Document documents = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // Indicates how imported documents are reconciled with the existing documents - // created or imported before. - enum ReconciliationMode { - // Defaults to INCREMENTAL. - RECONCILIATION_MODE_UNSPECIFIED = 0; - - // Inserts new documents or updates existing documents. - INCREMENTAL = 1; - - // Calculates diff and replaces the entire document dataset. Existing - // documents may be deleted if they are not present in the source location. - FULL = 2; - } - - // Required. The source of the input. - oneof source { - // The Inline source for the input content for documents. - InlineSource inline_source = 2; - - // Cloud Storage location for the input content. - GcsSource gcs_source = 3; - - // BigQuery input source. - BigQuerySource bigquery_source = 4; - } - - // Required. The parent branch resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - // Requires create/update permission. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Branch" - } - ]; - - // The desired location of errors incurred during the Import. - ImportErrorConfig error_config = 5; - - // The mode of reconciliation between existing documents and the documents to - // be imported. Defaults to - // [ReconciliationMode.INCREMENTAL][google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL]. - ReconciliationMode reconciliation_mode = 6; - - // Whether to automatically generate IDs for the documents if absent. - // - // If set to `true`, - // [Document.id][google.cloud.discoveryengine.v1.Document.id]s are - // automatically generated based on the hash of the payload, where IDs may not - // be consistent during multiple imports. In which case - // [ReconciliationMode.FULL][google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.FULL] - // is highly recommended to avoid duplicate contents. If unset or set to - // `false`, [Document.id][google.cloud.discoveryengine.v1.Document.id]s have - // to be specified using - // [id_field][google.cloud.discoveryengine.v1.ImportDocumentsRequest.id_field], - // otherwises, documents without IDs will fail to be imported. - // - // Only set this field when using - // [GcsSource][google.cloud.discoveryengine.v1.GcsSource] or - // [BigQuerySource][google.cloud.discoveryengine.v1.BigQuerySource], and when - // [GcsSource.data_schema][google.cloud.discoveryengine.v1.GcsSource.data_schema] - // or - // [BigQuerySource.data_schema][google.cloud.discoveryengine.v1.BigQuerySource.data_schema] - // is `custom`. Otherwise, an INVALID_ARGUMENT error is thrown. - bool auto_generate_ids = 8; - - // The field in the Cloud Storage and BigQuery sources that indicates the - // unique IDs of the documents. - // - // For [GcsSource][google.cloud.discoveryengine.v1.GcsSource] it is the key of - // the JSON field. For instance, `my_id` for JSON `{"my_id": "some_uuid"}`. - // For [BigQuerySource][google.cloud.discoveryengine.v1.BigQuerySource] it is - // the column name of the BigQuery table where the unique ids are stored. - // - // The values of the JSON field or the BigQuery column will be used as the - // [Document.id][google.cloud.discoveryengine.v1.Document.id]s. The JSON field - // or the BigQuery column must be of string type, and the values must be set - // as valid strings conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) - // with 1-63 characters. Otherwise, documents without valid IDs will fail to - // be imported. - // - // Only set this field when using - // [GcsSource][google.cloud.discoveryengine.v1.GcsSource] or - // [BigQuerySource][google.cloud.discoveryengine.v1.BigQuerySource], and when - // [GcsSource.data_schema][google.cloud.discoveryengine.v1.GcsSource.data_schema] - // or - // [BigQuerySource.data_schema][google.cloud.discoveryengine.v1.BigQuerySource.data_schema] - // is `custom`. And only set this field when - // [auto_generate_ids][google.cloud.discoveryengine.v1.ImportDocumentsRequest.auto_generate_ids] - // is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. - // - // If it is unset, a default value `_id` is used when importing from the - // allowed data sources. - string id_field = 9; -} - -// Response of the -// [ImportDocumentsRequest][google.cloud.discoveryengine.v1.ImportDocumentsRequest]. -// If the long running operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportDocumentsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ImportErrorConfig error_config = 2; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/purge_config.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/purge_config.proto deleted file mode 100644 index 8c0173b12c8..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/purge_config.proto +++ /dev/null @@ -1,86 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "PurgeConfigProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; - -// Request message for -// [DocumentService.PurgeDocuments][google.cloud.discoveryengine.v1.DocumentService.PurgeDocuments] -// method. -message PurgeDocumentsRequest { - // Required. The parent resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Branch" - } - ]; - - // Required. Filter matching documents to purge. Only currently supported - // value is - // `*` (all items). - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // Actually performs the purge. If `force` is set to false, return the - // expected purge count without deleting any documents. - bool force = 3; -} - -// Response message for -// [DocumentService.PurgeDocuments][google.cloud.discoveryengine.v1.DocumentService.PurgeDocuments] -// method. If the long running operation is successfully done, then this message -// is returned by the google.longrunning.Operations.response field. -message PurgeDocumentsResponse { - // The total count of documents purged as a result of the operation. - int64 purge_count = 1; - - // A sample of document names that will be deleted. Only populated if `force` - // is set to false. A max of 100 names will be returned and the names are - // chosen at random. - repeated string purge_sample = 2 [(google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Document" - }]; -} - -// Metadata related to the progress of the PurgeDocuments operation. -// This will be returned by the google.longrunning.Operation.metadata field. -message PurgeDocumentsMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were deleted successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema.proto deleted file mode 100644 index 1d8709acb12..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema.proto +++ /dev/null @@ -1,58 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "SchemaProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; - -// Defines the structure and layout of a type of document data. -message Schema { - option (google.api.resource) = { - type: "discoveryengine.googleapis.com/Schema" - pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}" - pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}" - }; - - // Schema representation. One of - // [struct_schema][google.cloud.discoveryengine.v1.Schema.struct_schema] or - // [json_schema][google.cloud.discoveryengine.v1.Schema.json_schema] should be - // provided otherwise an INVALID_ARGUMENT error is thrown. - oneof schema { - // The structured representation of the schema. - google.protobuf.Struct struct_schema = 2; - - // The JSON representation of the schema. - string json_schema = 3; - } - - // Immutable. The full resource name of the schema, in the format of - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - // - // This field must be a UTF-8 encoded string with a length limit of 1024 - // characters. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema_service.proto deleted file mode 100644 index 74ac7f70f5c..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/schema_service.proto +++ /dev/null @@ -1,256 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1/schema.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "SchemaServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; - -// Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s. -service SchemaService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Gets a [Schema][google.cloud.discoveryengine.v1.Schema]. - rpc GetSchema(GetSchemaRequest) returns (Schema) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/dataStores/*/schemas/*}" - additional_bindings { - get: "/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s. - rpc ListSchemas(ListSchemasRequest) returns (ListSchemasResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/dataStores/*}/schemas" - additional_bindings { - get: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/schemas" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a [Schema][google.cloud.discoveryengine.v1.Schema]. - rpc CreateSchema(CreateSchemaRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/dataStores/*}/schemas" - body: "schema" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/schemas" - body: "schema" - } - }; - option (google.api.method_signature) = "parent,schema,schema_id"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.discoveryengine.v1.Schema" - metadata_type: "google.cloud.discoveryengine.v1.CreateSchemaMetadata" - }; - } - - // Updates a [Schema][google.cloud.discoveryengine.v1.Schema]. - rpc UpdateSchema(UpdateSchemaRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{schema.name=projects/*/locations/*/dataStores/*/schemas/*}" - body: "schema" - additional_bindings { - patch: "/v1/{schema.name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" - body: "schema" - } - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.discoveryengine.v1.Schema" - metadata_type: "google.cloud.discoveryengine.v1.UpdateSchemaMetadata" - }; - } - - // Deletes a [Schema][google.cloud.discoveryengine.v1.Schema]. - rpc DeleteSchema(DeleteSchemaRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/dataStores/*/schemas/*}" - additional_bindings { - delete: "/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.discoveryengine.v1.DeleteSchemaMetadata" - }; - } -} - -// Request message for -// [SchemaService.GetSchema][google.cloud.discoveryengine.v1.SchemaService.GetSchema] -// method. -message GetSchemaRequest { - // Required. The full resource name of the schema, in the format of - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Schema" - } - ]; -} - -// Request message for -// [SchemaService.ListSchemas][google.cloud.discoveryengine.v1.SchemaService.ListSchemas] -// method. -message ListSchemasRequest { - // Required. The parent data store resource name, in the format of - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // The maximum number of [Schema][google.cloud.discoveryengine.v1.Schema]s to - // return. The service may return fewer than this value. - // - // If unspecified, at most 100 - // [Schema][google.cloud.discoveryengine.v1.Schema]s will be returned. - // - // The maximum value is 1000; values above 1000 will be coerced to 1000. - int32 page_size = 2; - - // A page token, received from a previous - // [SchemaService.ListSchemas][google.cloud.discoveryengine.v1.SchemaService.ListSchemas] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [SchemaService.ListSchemas][google.cloud.discoveryengine.v1.SchemaService.ListSchemas] - // must match the call that provided the page token. - string page_token = 3; -} - -// Response message for -// [SchemaService.ListSchemas][google.cloud.discoveryengine.v1.SchemaService.ListSchemas] -// method. -message ListSchemasResponse { - // The [Schema][google.cloud.discoveryengine.v1.Schema]s. - repeated Schema schemas = 1; - - // A token that can be sent as - // [ListSchemasRequest.page_token][google.cloud.discoveryengine.v1.ListSchemasRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request message for -// [SchemaService.CreateSchema][google.cloud.discoveryengine.v1.SchemaService.CreateSchema] -// method. -message CreateSchemaRequest { - // Required. The parent data store resource name, in the format of - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // Required. The [Schema][google.cloud.discoveryengine.v1.Schema] to create. - Schema schema = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the - // [Schema][google.cloud.discoveryengine.v1.Schema], which will become the - // final component of the - // [Schema.name][google.cloud.discoveryengine.v1.Schema.name]. - // - // This field should conform to - // [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length - // limit of 63 characters. - string schema_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for -// [SchemaService.UpdateSchema][google.cloud.discoveryengine.v1.SchemaService.UpdateSchema] -// method. -message UpdateSchemaRequest { - // Required. The [Schema][google.cloud.discoveryengine.v1.Schema] to update. - Schema schema = 1 [(google.api.field_behavior) = REQUIRED]; - - // If set to true, and the [Schema][google.cloud.discoveryengine.v1.Schema] is - // not found, a new [Schema][google.cloud.discoveryengine.v1.Schema] will be - // created. In this situation, `update_mask` is ignored. - bool allow_missing = 3; -} - -// Request message for -// [SchemaService.DeleteSchema][google.cloud.discoveryengine.v1.SchemaService.DeleteSchema] -// method. -message DeleteSchemaRequest { - // Required. The full resource name of the schema, in the format of - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Schema" - } - ]; -} - -// Metadata for Create Schema LRO. -message CreateSchemaMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; -} - -// Metadata for UpdateSchema LRO. -message UpdateSchemaMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; -} - -// Metadata for DeleteSchema LRO. -message DeleteSchemaMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/search_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/search_service.proto deleted file mode 100644 index 6062d593cae..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/search_service.proto +++ /dev/null @@ -1,289 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1/common.proto"; -import "google/cloud/discoveryengine/v1/document.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "SearchServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; - -// Service for search. -service SearchService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Performs a search. - rpc Search(SearchRequest) returns (SearchResponse) { - option (google.api.http) = { - post: "/v1/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:search" - body: "*" - additional_bindings { - post: "/v1/{serving_config=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:search" - body: "*" - } - }; - } -} - -// Request message for -// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] -// method. -message SearchRequest { - // Specification to determine under which conditions query expansion should - // occur. - message QueryExpansionSpec { - // Enum describing under which condition query expansion should occur. - enum Condition { - // Unspecified query expansion condition. In this case, server behavior - // defaults to - // [Condition.DISABLED][google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - CONDITION_UNSPECIFIED = 0; - - // Disabled query expansion. Only the exact search query is used, even if - // [SearchResponse.total_size][google.cloud.discoveryengine.v1.SearchResponse.total_size] - // is zero. - DISABLED = 1; - - // Automatic query expansion built by the Search API. - AUTO = 2; - } - - // The condition under which query expansion should occur. Default to - // [Condition.DISABLED][google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - Condition condition = 1; - } - - // The specification for query spell correction. - message SpellCorrectionSpec { - // Enum describing under which mode spell correction should occur. - enum Mode { - // Unspecified spell correction mode. In this case, server behavior - // defaults to - // [Mode.AUTO][google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Search API will try to find a spell suggestion if there - // is any and put in the - // [SearchResponse.corrected_query][google.cloud.discoveryengine.v1.SearchResponse.corrected_query]. - // The spell suggestion will not be used as the search query. - SUGGESTION_ONLY = 1; - - // Automatic spell correction built by the Search API. Search will - // be based on the corrected query if found. - AUTO = 2; - } - - // The mode under which spell correction should take effect to - // replace the original search query. Default to - // [Mode.AUTO][google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. - Mode mode = 1; - } - - // The specification that configs the desired behavior of the UCS content - // search. - message ContentSearchSpec { - // The specification that configs the snippet in the search results. - message SnippetSpec { - // Max number of snippets returned in each search result. - // If the matching snippets is less than the max_snippet_count, return all - // of the snippets; otherwise, return the max_snippet_count. - // - // At most 5 snippets will be returned for each SearchResult. - int32 max_snippet_count = 1; - - // if true, only snippet reference is returned. - bool reference_only = 2; - } - - // If there is no snippet spec provided, there will be no snippet in the - // search result. - SnippetSpec snippet_spec = 1; - } - - // Required. The resource name of the Search serving config, such as - // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. - // This field is used to identify the serving configuration name, set - // of models used to make the search. - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/ServingConfig" - } - ]; - - // The branch resource name, such as - // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. - // - // Use `default_branch` as the branch ID or leave this field empty, to search - // documents under the default branch. - string branch = 2 [(google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Branch" - }]; - - // Raw search query. - string query = 3; - - // Maximum number of [Document][google.cloud.discoveryengine.v1.Document]s to - // return. If unspecified, defaults to a reasonable value. The maximum allowed - // value is 100. Values above 100 will be coerced to 100. - // - // If this field is negative, an `INVALID_ARGUMENT` is returned. - int32 page_size = 4; - - // A page token received from a previous - // [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] - // must match the call that provided the page token. Otherwise, an - // `INVALID_ARGUMENT` error is returned. - string page_token = 5; - - // A 0-indexed integer that specifies the current offset (that is, starting - // result location, amongst the - // [Document][google.cloud.discoveryengine.v1.Document]s deemed by the API as - // relevant) in search results. This field is only considered if - // [page_token][google.cloud.discoveryengine.v1.SearchRequest.page_token] is - // unset. - // - // If this field is negative, an `INVALID_ARGUMENT` is returned. - int32 offset = 6; - - // Information about the end user. - // Highly recommended for analytics. The user_agent string in UserInfo will - // be used to deduce device_type for analytics. - UserInfo user_info = 21; - - // Additional search parameters. - // - // For public website search only, supported values are: - // - // * `user_country_code`: string. Default empty. If set to non-empty, results - // are restricted or boosted based on the location provided. - // * `search_type`: double. Default empty. Enables non-webpage searching - // depending on the value. The only valid non-default value is 1, - // which enables image searching. - map params = 11; - - // The query expansion specification that specifies the conditions under which - // query expansion will occur. - QueryExpansionSpec query_expansion_spec = 13; - - // The spell correction specification that specifies the mode under - // which spell correction will take effect. - SpellCorrectionSpec spell_correction_spec = 14; - - // 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. - // - // This field should NOT have a fixed value such as `unknown_visitor`. - // - // This should be the same identifier as - // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id] - // and - // [CompleteQueryRequest.user_pseudo_id][google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id] - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - string user_pseudo_id = 15; - - // The content search spec that configs the desired behavior of content - // search. - ContentSearchSpec content_search_spec = 24; - - // Whether to turn on safe search. This is only supported for - // [ContentConfig.PUBLIC_WEBSITE][]. - bool safe_search = 20; - - // The user 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. - map user_labels = 22; -} - -// Response message for -// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search] -// method. -message SearchResponse { - // Represents the search results. - message SearchResult { - // [Document.id][google.cloud.discoveryengine.v1.Document.id] of the - // searched [Document][google.cloud.discoveryengine.v1.Document]. - string id = 1; - - // The document data snippet in the search response. Only fields that are - // marked as retrievable are populated. - Document document = 2; - } - - // A list of matched documents. The order represents the ranking. - repeated SearchResult results = 1; - - // The estimated total count of matched items irrespective of pagination. The - // count of [results][google.cloud.discoveryengine.v1.SearchResponse.results] - // returned by pagination may be less than the - // [total_size][google.cloud.discoveryengine.v1.SearchResponse.total_size] - // that matches. - int32 total_size = 3; - - // A unique search token. This should be included in the - // [UserEvent][google.cloud.discoveryengine.v1.UserEvent] logs resulting from - // this search, which enables accurate attribution of search model - // performance. - string attribution_token = 4; - - // A token that can be sent as - // [SearchRequest.page_token][google.cloud.discoveryengine.v1.SearchRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 5; - - // Contains the spell corrected query, if found. If the spell correction type - // is AUTOMATIC, then the search results are based on corrected_query. - // Otherwise the original query is used for search. - string corrected_query = 7; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event.proto deleted file mode 100644 index f141a2911e4..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event.proto +++ /dev/null @@ -1,458 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1/common.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "UserEventProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; - -// UserEvent captures all metadata information Discovery Engine API needs to -// know about how end users interact with customers' website. -message UserEvent { - // Required. User event type. Allowed values are: - // - // Generic values: - // - // * `search`: Search for Documents. - // * `view-item`: Detailed page view of a Document. - // * `view-item-list`: View of a panel or ordered list of Documents. - // * `view-home-page`: View of the home page. - // * `view-category-page`: View of a category page, e.g. Home > Men > Jeans - // - // Retail-related values: - // - // * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping - // * `purchase`: Purchase an item(s) - // - // Media-related values: - // - // * `media-play`: Start/resume watching a video, playing a song, etc. - // * `media-complete`: Finished or stopped midway through a video, song, etc. - string event_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. 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 log in/out of the website. - // - // Do not set the field to the same fixed ID for different users. This mixes - // the event history of those users together, which results in degraded model - // quality. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // The field should not contain PII or user-data. We recommend to use Google - // Analytics [Client - // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) - // for this field. - string user_pseudo_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Only required for - // [UserEventService.ImportUserEvents][google.cloud.discoveryengine.v1.UserEventService.ImportUserEvents] - // method. Timestamp of when the user event happened. - google.protobuf.Timestamp event_time = 3; - - // Information about the end user. - UserInfo user_info = 4; - - // Should set to true if the request is made directly from the end user, in - // which case the - // [UserEvent.user_info.user_agent][google.cloud.discoveryengine.v1.UserInfo.user_agent] - // can be populated from the HTTP request. - // - // This flag should be set only if the API request is made directly from the - // end user such as a mobile app (and not if a gateway or a server is - // processing and pushing the user events). - // - // This should not be set when using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1.UserEventService.CollectUserEvent]. - bool direct_user_request = 5; - - // A unique identifier for tracking a visitor session with a length limit of - // 128 bytes. A session is an aggregation of an end user behavior in a time - // span. - // - // A general guideline to populate the session_id: - // - // 1. If user has no activity for 30 min, a new session_id should be assigned. - // 2. The session_id should be unique across users, suggest use uuid or add - // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id] - // as prefix. - string session_id = 6; - - // Page metadata such as categories and other critical information for certain - // event types such as `view-category-page`. - PageInfo page_info = 7; - - // Token to attribute an API response to user action(s) to trigger the event. - // - // Highly recommended for user events that are the result of - // [RecommendationService.Recommend][]. This field enables accurate - // attribution of recommendation model performance. - // - // The value must be one of: - // - // * [PredictResponse.attribution_token][] for events that are the result of - // [RecommendationService.Recommend][]. - // * [SearchResponse.attribution_token][google.cloud.discoveryengine.v1.SearchResponse.attribution_token] for events that are the result of - // [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]. - // * [CompleteQueryResponse.attribution_token][] for events that are the - // result of - // [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1.CompletionService.CompleteQuery]. - // - // This token enables us to accurately attribute page view or conversion - // completion back to the event and the particular predict response containing - // this clicked/purchased product. If user clicks on product K in the - // recommendation results, pass [PredictResponse.attribution_token][] as a URL - // parameter to product K's page. When recording events on product K's page, - // log the [PredictResponse.attribution_token][] to this field. - string attribution_token = 8; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the documents being filtered. - // - // One example is for `search` events, the associated - // [SearchRequest][google.cloud.discoveryengine.v1.SearchRequest] may contain - // a filter expression in [SearchRequest.filter][] conforming to - // https://google.aip.dev/160#filtering. - // - // Similarly, for `view-item-list` events that are generated from a - // [RecommendationService.RecommendRequest][], this field may be populated - // directly from [RecommendationService.RecommendRequest.filter][] conforming - // to https://google.aip.dev/160#filtering. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string filter = 9; - - // List of Documents associated with this user event. - // - // This field is optional except for the following event types: - // - // * `view-item` - // * `add-to-cart` - // * `purchase` - // * `media-play` - // * `media-complete` - // - // In a `search` event, this field represents the documents returned to the - // end user on the current page (the end user may have not finished browsing - // the whole page yet). When a new page is returned to the end user, after - // pagination/filtering/ordering even for the same query, a new `search` event - // with different - // [UserEvent.documents][google.cloud.discoveryengine.v1.UserEvent.documents] - // is desired. - repeated DocumentInfo documents = 10; - - // Panel metadata associated with this user event. - PanelInfo panel = 11; - - // Search API details related to the event. - // - // This field should be set for `search` event. - SearchInfo search_info = 12; - - // CompleteQuery API details related to the event. - // - // This field should be set for `search` event when autocomplete function is - // enabled and the user clicks a suggestion for search. - CompletionInfo completion_info = 13; - - // The transaction metadata (if any) associated with this user event. - TransactionInfo transaction_info = 14; - - // A list of identifiers for the independent experiment groups this user event - // belongs to. This is used to distinguish between user events associated with - // different experiment setups on the customer end. - repeated string tag_ids = 15; - - // The promotion IDs if this is an event associated with promotions. - // Currently, this field is restricted to at most one ID. - repeated string promotion_ids = 16; - - // Extra user event features to include in the recommendation model. - // These attributes must NOT contain data that needs to be parsed or processed - // further, e.g. JSON or other encodings. - // - // If you provide custom attributes for ingested user events, also include - // them in the user events that you associate with prediction requests. Custom - // attribute formatting must be consistent between imported events and events - // provided with prediction requests. This lets the Discovery Engine API use - // those custom attributes when training models and serving predictions, which - // helps improve recommendation quality. - // - // This field needs to pass all below criteria, otherwise an - // `INVALID_ARGUMENT` error is returned: - // - // * The key must be a UTF-8 encoded string with a length limit of 5,000 - // characters. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 256 characters. - // * For number attributes, at most 400 values are allowed. - // - // For product recommendations, an example of extra user information is - // ` traffic_channel`, which is how a user arrives at the site. Users can - // arrive - // at the site by coming to the site directly, coming through Google - // search, or in other ways. - map attributes = 17; - - // Media-specific info. - MediaInfo media_info = 18; -} - -// Detailed page information. -message PageInfo { - // A unique ID of a web page view. - // - // This should be kept the same for all user events triggered from the same - // pageview. For example, an item detail page view could trigger multiple - // events as the user is browsing the page. The `pageViewId` property should - // be kept the same for all these events so that they can be grouped together - // properly. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string pageview_id = 1; - - // The most specific category associated with a category page. - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategory" : "Sales > 2017 Black Friday Deals". - // - // Required for `view-category-page` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - string page_category = 2; - - // Complete URL (window.location.href) of the user's current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. Maximum length 5,000 - // characters. - string uri = 3; - - // The referrer URL of the current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. However, some browser - // privacy restrictions may cause this field to be empty. - string referrer_uri = 4; -} - -// Detailed search information. -message SearchInfo { - // The user's search query. - // - // See - // [SearchRequest.query][google.cloud.discoveryengine.v1.SearchRequest.query] - // for definition. - // - // The value must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // At least one of - // [search_query][google.cloud.discoveryengine.v1.SearchInfo.search_query] or - // [PageInfo.page_category][google.cloud.discoveryengine.v1.PageInfo.page_category] - // is required for `search` events. Other event types should not set this - // field. Otherwise, an INVALID_ARGUMENT error is returned. - string search_query = 1; - - // The order in which products are returned, if applicable. - // - // See [SearchRequest.order_by][] for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - string order_by = 2; - - // An integer that specifies the current offset for pagination (the 0-indexed - // starting location, amongst the products deemed by the API as relevant). - // - // See - // [SearchRequest.offset][google.cloud.discoveryengine.v1.SearchRequest.offset] - // for definition. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - optional int32 offset = 3; -} - -// Detailed completion information including completion attribution token and -// clicked completion info. -message CompletionInfo { - // End user selected [CompleteQueryResponse.CompletionResult.suggestion][]. - string selected_suggestion = 1; - - // End user selected [CompleteQueryResponse.CompletionResult.suggestion][] - // position, starting from 0. - int32 selected_position = 2; -} - -// A transaction represents the entire purchase transaction. -message TransactionInfo { - // Required. Total non-zero value associated with the transaction. This value - // may include shipping, tax, or other adjustments to the total value that you - // want to include. - optional float value = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Currency code. Use three-character ISO-4217 code. - string currency = 2 [(google.api.field_behavior) = REQUIRED]; - - // The transaction ID with a length limit of 128 characters. - string transaction_id = 3; - - // All the taxes associated with the transaction. - optional float tax = 4; - - // All the costs associated with the products. These can be manufacturing - // costs, shipping expenses not borne by the end user, or any other costs, - // such that: - // - // * Profit = [value][google.cloud.discoveryengine.v1.TransactionInfo.value] - - // [tax][google.cloud.discoveryengine.v1.TransactionInfo.tax] - - // [cost][google.cloud.discoveryengine.v1.TransactionInfo.cost] - optional float cost = 5; - - // The total discount(s) value applied to this transaction. - // This figure should be excluded from - // [TransactionInfo.value][google.cloud.discoveryengine.v1.TransactionInfo.value] - // - // For example, if a user paid - // [TransactionInfo.value][google.cloud.discoveryengine.v1.TransactionInfo.value] - // amount, then nominal (pre-discount) value of the transaction is the sum of - // [TransactionInfo.value][google.cloud.discoveryengine.v1.TransactionInfo.value] - // and - // [TransactionInfo.discount_value][google.cloud.discoveryengine.v1.TransactionInfo.discount_value] - // - // This means that profit is calculated the same way, regardless of the - // discount value, and that - // [TransactionInfo.discount_value][google.cloud.discoveryengine.v1.TransactionInfo.discount_value] - // can be larger than - // [TransactionInfo.value][google.cloud.discoveryengine.v1.TransactionInfo.value]: - // - // * Profit = [value][google.cloud.discoveryengine.v1.TransactionInfo.value] - - // [tax][google.cloud.discoveryengine.v1.TransactionInfo.tax] - - // [cost][google.cloud.discoveryengine.v1.TransactionInfo.cost] - optional float discount_value = 6; -} - -// Detailed document information associated with a user event. -message DocumentInfo { - // A required descriptor of the associated - // [Document][google.cloud.discoveryengine.v1.Document]. - // - // * If [id][google.cloud.discoveryengine.v1.DocumentInfo.id] is specified, - // then the default values for - // `{location}`, `{collection_id}`, `{data_store_id}`, and `{branch_id}` are - // used when annotating with the stored Document. - // - // * If [name][google.cloud.discoveryengine.v1.DocumentInfo.name] is - // specified, then the provided values (default values allowed) for - // `{location}`, `{collection_id}`, `{data_store_id}`, and - // `{branch_id}` are used when annotating with the stored Document. - oneof document_descriptor { - // Required. The Document resource ID. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The Document resource full name, of the form: - // `projects/{project_id}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}` - string name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Document" - } - ]; - } - - // Quantity of the Document associated with the user event. Defaults to 1. - // - // For example, this field will be 2 if two quantities of the same Document - // are involved in a `add-to-cart` event. - // - // Required for events of the following event types: - // - // * `add-to-cart` - // * `purchase` - optional int32 quantity = 3; - - // The promotion IDs associated with this Document. - // Currently, this field is restricted to at most one ID. - repeated string promotion_ids = 4; -} - -// Detailed panel information associated with a user event. -message PanelInfo { - // Required. The panel ID. - string panel_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // The display name of the panel. - string display_name = 3; - - // The ordered position of the panel, if shown to the user with other panels. - // If set, then - // [total_panels][google.cloud.discoveryengine.v1.PanelInfo.total_panels] must - // also be set. - optional int32 panel_position = 4; - - // The total number of panels, including this one, shown to the user. - // Must be set if - // [panel_position][google.cloud.discoveryengine.v1.PanelInfo.panel_position] - // is set. - optional int32 total_panels = 5; -} - -// Media-specific user event information. -message MediaInfo { - // The media progress time in seconds, if applicable. - // For example, if the end user has finished 90 seconds of a playback video, - // then [MediaInfo.media_progress_duration.seconds][Duration.seconds] should - // be set to 90. - google.protobuf.Duration media_progress_duration = 1; - - // Media progress should be computed using only the media_progress_duration - // relative to the media total length. - // - // This value must be between `[0, 1.0]` inclusive. - // - // If this is not a playback or the progress cannot be computed (e.g. ongoing - // livestream), this field should be unset. - optional float media_progress_percentage = 2; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event_service.proto deleted file mode 100644 index 4dbeea46c58..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/protos/google/cloud/discoveryengine/v1/user_event_service.proto +++ /dev/null @@ -1,133 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/httpbody.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1/import_config.proto"; -import "google/cloud/discoveryengine/v1/user_event.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "UserEventServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1"; - -// Service for ingesting end user actions on a website to Discovery Engine API. -service UserEventService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Writes a single user event. - rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/dataStores/*}/userEvents:write" - body: "user_event" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:write" - body: "user_event" - } - }; - } - - // Writes a single user event from the browser. This uses a GET request to - // due to browser restriction of POST-ing to a 3rd party domain. - // - // This method is used only by the Discovery Engine API JavaScript pixel and - // Google Tag Manager. Users should not call this method directly. - rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/dataStores/*}/userEvents:collect" - additional_bindings { - get: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:collect" - } - }; - } - - // Bulk import of User events. Request processing might be - // synchronous. Events that already exist are skipped. - // Use this method for backfilling historical user events. - // - // Operation.response is of type ImportResponse. Note that it is - // possible for a subset of the items to be successfully inserted. - // Operation.metadata is of type ImportMetadata. - rpc ImportUserEvents(ImportUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/dataStores/*}/userEvents:import" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:import" - body: "*" - } - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.discoveryengine.v1.ImportUserEventsResponse" - metadata_type: "google.cloud.discoveryengine.v1.ImportUserEventsMetadata" - }; - } -} - -// Request message for WriteUserEvent method. -message WriteUserEventRequest { - // Required. The parent DataStore resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // Required. User event to write. - optional UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // Required. The parent DataStore resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // Required. URL encoded UserEvent proto with a length limit of 2,000,000 - // characters. - string user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // 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. - optional string uri = 3; - - // The event timestamp in milliseconds. This prevents browser caching of - // otherwise identical get requests. The name is abbreviated to reduce the - // payload bytes. - optional int64 ets = 4; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/completion_service.complete_query.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/completion_service.complete_query.js deleted file mode 100644 index 3b28773bbfe..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/completion_service.complete_query.js +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2023 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(dataStore, query) { - // [START discoveryengine_v1_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. The parent data store resource name for which the completion is - * performed, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store`. - */ - // const dataStore = 'abc123' - /** - * Required. The typeahead input used to fetch suggestions. Maximum length is - * 128 characters. - */ - // const query = 'abc123' - /** - * Selects data model of query suggestions for serving. Currently supported - * values: - * * `document` - Using suggestions generated from user-imported documents. - * * `search-history` - Using suggestions generated from the past history of - * SearchService.Search google.cloud.discoveryengine.v1.SearchService.Search - * API calls. Do not use it when there is no traffic for Search API. - * * `user-event` - Using suggestions generated from user-imported search - * events. - * Default values: - * * `document` is the default model for regular dataStores. - * * `search-history` is the default model for - * IndustryVertical.SITE_SEARCH google.cloud.discoveryengine.v1.IndustryVertical.SITE_SEARCH - * dataStores. - */ - // const queryModel = 'abc123' - /** - * 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. - * This field should NOT have a fixed value such as `unknown_visitor`. - * This should be the same identifier as - * UserEvent.user_pseudo_id google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id - * and - * SearchRequest.user_pseudo_id google.cloud.discoveryengine.v1.SearchRequest.user_pseudo_id. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - */ - // const userPseudoId = 'abc123' - - // Imports the Discoveryengine library - const {CompletionServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new CompletionServiceClient(); - - async function callCompleteQuery() { - // Construct request - const request = { - dataStore, - query, - }; - - // Run request - const response = await discoveryengineClient.completeQuery(request); - console.log(response); - } - - callCompleteQuery(); - // [END discoveryengine_v1_generated_CompletionService_CompleteQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.create_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.create_document.js deleted file mode 100644 index ecc3fd1a633..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.create_document.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2023 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, document, documentId) { - // [START discoveryengine_v1_generated_DocumentService_CreateDocument_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 resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - */ - // const parent = 'abc123' - /** - * Required. The Document google.cloud.discoveryengine.v1.Document to - * create. - */ - // const document = {} - /** - * Required. The ID to use for the - * Document google.cloud.discoveryengine.v1.Document, which will become the - * final component of the - * Document.name google.cloud.discoveryengine.v1.Document.name. - * If the caller does not have permission to create the - * Document google.cloud.discoveryengine.v1.Document, regardless of whether - * or not it exists, a `PERMISSION_DENIED` error is returned. - * This field must be unique among all - * Document google.cloud.discoveryengine.v1.Document s with the same - * parent google.cloud.discoveryengine.v1.CreateDocumentRequest.parent. - * Otherwise, an `ALREADY_EXISTS` error is returned. - * This field must conform to RFC-1034 (https://tools.ietf.org/html/rfc1034) - * standard with a length limit of 63 characters. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - */ - // const documentId = 'abc123' - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callCreateDocument() { - // Construct request - const request = { - parent, - document, - documentId, - }; - - // Run request - const response = await discoveryengineClient.createDocument(request); - console.log(response); - } - - callCreateDocument(); - // [END discoveryengine_v1_generated_DocumentService_CreateDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.delete_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.delete_document.js deleted file mode 100644 index 07ea8d63758..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.delete_document.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_generated_DocumentService_DeleteDocument_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 - * Document google.cloud.discoveryengine.v1.Document, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - * If the caller does not have permission to delete the - * Document google.cloud.discoveryengine.v1.Document, regardless of whether - * or not it exists, a `PERMISSION_DENIED` error is returned. - * If the Document google.cloud.discoveryengine.v1.Document to delete does - * not exist, a `NOT_FOUND` error is returned. - */ - // const name = 'abc123' - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callDeleteDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await discoveryengineClient.deleteDocument(request); - console.log(response); - } - - callDeleteDocument(); - // [END discoveryengine_v1_generated_DocumentService_DeleteDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.get_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.get_document.js deleted file mode 100644 index c841cd21a70..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.get_document.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_generated_DocumentService_GetDocument_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 - * Document google.cloud.discoveryengine.v1.Document, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - * If the caller does not have permission to access the - * Document google.cloud.discoveryengine.v1.Document, regardless of whether - * or not it exists, a `PERMISSION_DENIED` error is returned. - * If the requested Document google.cloud.discoveryengine.v1.Document does - * not exist, a `NOT_FOUND` error is returned. - */ - // const name = 'abc123' - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callGetDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await discoveryengineClient.getDocument(request); - console.log(response); - } - - callGetDocument(); - // [END discoveryengine_v1_generated_DocumentService_GetDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.import_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.import_documents.js deleted file mode 100644 index 575940b0b67..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.import_documents.js +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_generated_DocumentService_ImportDocuments_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 Inline source for the input content for documents. - */ - // const inlineSource = {} - /** - * Cloud Storage location for the input content. - */ - // const gcsSource = {} - /** - * BigQuery input source. - */ - // const bigquerySource = {} - /** - * Required. The parent branch resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Requires create/update permission. - */ - // const parent = 'abc123' - /** - * The desired location of errors incurred during the Import. - */ - // const errorConfig = {} - /** - * The mode of reconciliation between existing documents and the documents to - * be imported. Defaults to - * ReconciliationMode.INCREMENTAL google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL. - */ - // const reconciliationMode = {} - /** - * Whether to automatically generate IDs for the documents if absent. - * If set to `true`, - * Document.id google.cloud.discoveryengine.v1.Document.id s are - * automatically generated based on the hash of the payload, where IDs may not - * be consistent during multiple imports. In which case - * ReconciliationMode.FULL google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.FULL - * is highly recommended to avoid duplicate contents. If unset or set to - * `false`, Document.id google.cloud.discoveryengine.v1.Document.id s have - * to be specified using - * id_field google.cloud.discoveryengine.v1.ImportDocumentsRequest.id_field, - * otherwises, documents without IDs will fail to be imported. - * Only set this field when using - * GcsSource google.cloud.discoveryengine.v1.GcsSource or - * BigQuerySource google.cloud.discoveryengine.v1.BigQuerySource, and when - * GcsSource.data_schema google.cloud.discoveryengine.v1.GcsSource.data_schema - * or - * BigQuerySource.data_schema google.cloud.discoveryengine.v1.BigQuerySource.data_schema - * is `custom`. Otherwise, an INVALID_ARGUMENT error is thrown. - */ - // const autoGenerateIds = true - /** - * The field in the Cloud Storage and BigQuery sources that indicates the - * unique IDs of the documents. - * For GcsSource google.cloud.discoveryengine.v1.GcsSource it is the key of - * the JSON field. For instance, `my_id` for JSON `{"my_id": "some_uuid"}`. - * For BigQuerySource google.cloud.discoveryengine.v1.BigQuerySource it is - * the column name of the BigQuery table where the unique ids are stored. - * The values of the JSON field or the BigQuery column will be used as the - * Document.id google.cloud.discoveryengine.v1.Document.id s. The JSON field - * or the BigQuery column must be of string type, and the values must be set - * as valid strings conform to RFC-1034 (https://tools.ietf.org/html/rfc1034) - * with 1-63 characters. Otherwise, documents without valid IDs will fail to - * be imported. - * Only set this field when using - * GcsSource google.cloud.discoveryengine.v1.GcsSource or - * BigQuerySource google.cloud.discoveryengine.v1.BigQuerySource, and when - * GcsSource.data_schema google.cloud.discoveryengine.v1.GcsSource.data_schema - * or - * BigQuerySource.data_schema google.cloud.discoveryengine.v1.BigQuerySource.data_schema - * is `custom`. And only set this field when - * auto_generate_ids google.cloud.discoveryengine.v1.ImportDocumentsRequest.auto_generate_ids - * is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. - * If it is unset, a default value `_id` is used when importing from the - * allowed data sources. - */ - // const idField = 'abc123' - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callImportDocuments() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await discoveryengineClient.importDocuments(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportDocuments(); - // [END discoveryengine_v1_generated_DocumentService_ImportDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.list_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.list_documents.js deleted file mode 100644 index 35776f52b3b..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.list_documents.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_generated_DocumentService_ListDocuments_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/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Use `default_branch` as the branch ID, to list documents under the default - * branch. - * If the caller does not have permission to list Documents s under this - * branch, regardless of whether or not this branch exists, a - * `PERMISSION_DENIED` error is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Document google.cloud.discoveryengine.v1.Document 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 - * ListDocumentsResponse.next_page_token google.cloud.discoveryengine.v1.ListDocumentsResponse.next_page_token, - * received from a previous - * DocumentService.ListDocuments google.cloud.discoveryengine.v1.DocumentService.ListDocuments - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * DocumentService.ListDocuments google.cloud.discoveryengine.v1.DocumentService.ListDocuments - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - */ - // const pageToken = 'abc123' - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callListDocuments() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await discoveryengineClient.listDocumentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListDocuments(); - // [END discoveryengine_v1_generated_DocumentService_ListDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.purge_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.purge_documents.js deleted file mode 100644 index e16e9efda70..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.purge_documents.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_generated_DocumentService_PurgeDocuments_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 resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - */ - // const parent = 'abc123' - /** - * Required. Filter matching documents to purge. Only currently supported - * value is - * `*` (all items). - */ - // const filter = 'abc123' - /** - * Actually performs the purge. If `force` is set to false, return the - * expected purge count without deleting any documents. - */ - // const force = true - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callPurgeDocuments() { - // Construct request - const request = { - parent, - filter, - }; - - // Run request - const [operation] = await discoveryengineClient.purgeDocuments(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeDocuments(); - // [END discoveryengine_v1_generated_DocumentService_PurgeDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.update_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.update_document.js deleted file mode 100644 index 34a13e9d7db..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/document_service.update_document.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2023 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(document) { - // [START discoveryengine_v1_generated_DocumentService_UpdateDocument_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 document to update/create. - * If the caller does not have permission to update the - * Document google.cloud.discoveryengine.v1.Document, regardless of whether - * or not it exists, a `PERMISSION_DENIED` error is returned. - * If the Document google.cloud.discoveryengine.v1.Document to update does - * not exist and - * allow_missing google.cloud.discoveryengine.v1.UpdateDocumentRequest.allow_missing - * is not set, a `NOT_FOUND` error is returned. - */ - // const document = {} - /** - * If set to true, and the - * Document google.cloud.discoveryengine.v1.Document is not found, a new - * Document google.cloud.discoveryengine.v1.Document will be created. - */ - // const allowMissing = true - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callUpdateDocument() { - // Construct request - const request = { - document, - }; - - // Run request - const response = await discoveryengineClient.updateDocument(request); - console.log(response); - } - - callUpdateDocument(); - // [END discoveryengine_v1_generated_DocumentService_UpdateDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.create_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.create_schema.js deleted file mode 100644 index c3858db0cc9..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.create_schema.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2023 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, schema, schemaId) { - // [START discoveryengine_v1_generated_SchemaService_CreateSchema_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 data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - */ - // const parent = 'abc123' - /** - * Required. The Schema google.cloud.discoveryengine.v1.Schema to create. - */ - // const schema = {} - /** - * Required. The ID to use for the - * Schema google.cloud.discoveryengine.v1.Schema, which will become the - * final component of the - * Schema.name google.cloud.discoveryengine.v1.Schema.name. - * This field should conform to - * RFC-1034 (https://tools.ietf.org/html/rfc1034) standard with a length - * limit of 63 characters. - */ - // const schemaId = 'abc123' - - // Imports the Discoveryengine library - const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new SchemaServiceClient(); - - async function callCreateSchema() { - // Construct request - const request = { - parent, - schema, - schemaId, - }; - - // Run request - const [operation] = await discoveryengineClient.createSchema(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateSchema(); - // [END discoveryengine_v1_generated_SchemaService_CreateSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.delete_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.delete_schema.js deleted file mode 100644 index 453197cb6ac..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.delete_schema.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_generated_SchemaService_DeleteSchema_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 full resource name of the schema, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - */ - // const name = 'abc123' - - // Imports the Discoveryengine library - const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new SchemaServiceClient(); - - async function callDeleteSchema() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await discoveryengineClient.deleteSchema(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteSchema(); - // [END discoveryengine_v1_generated_SchemaService_DeleteSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.get_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.get_schema.js deleted file mode 100644 index bead062baab..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.get_schema.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_generated_SchemaService_GetSchema_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 full resource name of the schema, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - */ - // const name = 'abc123' - - // Imports the Discoveryengine library - const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new SchemaServiceClient(); - - async function callGetSchema() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await discoveryengineClient.getSchema(request); - console.log(response); - } - - callGetSchema(); - // [END discoveryengine_v1_generated_SchemaService_GetSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.list_schemas.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.list_schemas.js deleted file mode 100644 index 892e642a95e..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.list_schemas.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_generated_SchemaService_ListSchemas_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 data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - */ - // const parent = 'abc123' - /** - * The maximum number of Schema google.cloud.discoveryengine.v1.Schema s to - * return. The service may return fewer than this value. - * If unspecified, at most 100 - * Schema google.cloud.discoveryengine.v1.Schema s will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - */ - // const pageSize = 1234 - /** - * A page token, received from a previous - * SchemaService.ListSchemas google.cloud.discoveryengine.v1.SchemaService.ListSchemas - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * SchemaService.ListSchemas google.cloud.discoveryengine.v1.SchemaService.ListSchemas - * must match the call that provided the page token. - */ - // const pageToken = 'abc123' - - // Imports the Discoveryengine library - const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new SchemaServiceClient(); - - async function callListSchemas() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await discoveryengineClient.listSchemasAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListSchemas(); - // [END discoveryengine_v1_generated_SchemaService_ListSchemas_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.update_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.update_schema.js deleted file mode 100644 index 280538e4532..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/schema_service.update_schema.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 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(schema) { - // [START discoveryengine_v1_generated_SchemaService_UpdateSchema_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 Schema google.cloud.discoveryengine.v1.Schema to update. - */ - // const schema = {} - /** - * If set to true, and the Schema google.cloud.discoveryengine.v1.Schema is - * not found, a new Schema google.cloud.discoveryengine.v1.Schema will be - * created. In this situation, `update_mask` is ignored. - */ - // const allowMissing = true - - // Imports the Discoveryengine library - const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new SchemaServiceClient(); - - async function callUpdateSchema() { - // Construct request - const request = { - schema, - }; - - // Run request - const [operation] = await discoveryengineClient.updateSchema(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateSchema(); - // [END discoveryengine_v1_generated_SchemaService_UpdateSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/search_service.search.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/search_service.search.js deleted file mode 100644 index 58f51dba0ed..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/search_service.search.js +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_generated_SearchService_Search_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 Search serving config, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. - * This field is used to identify the serving configuration name, set - * of models used to make the search. - */ - // const servingConfig = 'abc123' - /** - * The branch resource name, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. - * Use `default_branch` as the branch ID or leave this field empty, to search - * documents under the default branch. - */ - // const branch = 'abc123' - /** - * Raw search query. - */ - // const query = 'abc123' - /** - * Maximum number of Document google.cloud.discoveryengine.v1.Document s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 100. Values above 100 will be coerced to 100. - * If this field is negative, an `INVALID_ARGUMENT` is returned. - */ - // const pageSize = 1234 - /** - * A page token received from a previous - * SearchService.Search google.cloud.discoveryengine.v1.SearchService.Search - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * SearchService.Search google.cloud.discoveryengine.v1.SearchService.Search - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - */ - // const pageToken = 'abc123' - /** - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * Document google.cloud.discoveryengine.v1.Document s deemed by the API as - * relevant) in search results. This field is only considered if - * page_token google.cloud.discoveryengine.v1.SearchRequest.page_token is - * unset. - * If this field is negative, an `INVALID_ARGUMENT` is returned. - */ - // const offset = 1234 - /** - * Information about the end user. - * Highly recommended for analytics. The user_agent string in UserInfo will - * be used to deduce device_type for analytics. - */ - // const userInfo = {} - /** - * Additional search parameters. - * For public website search only, supported values are: - * * `user_country_code`: string. Default empty. If set to non-empty, results - * are restricted or boosted based on the location provided. - * * `search_type`: double. Default empty. Enables non-webpage searching - * depending on the value. The only valid non-default value is 1, - * which enables image searching. - */ - // const params = 1234 - /** - * The query expansion specification that specifies the conditions under which - * query expansion will occur. - */ - // const queryExpansionSpec = {} - /** - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - */ - // const spellCorrectionSpec = {} - /** - * 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. - * This field should NOT have a fixed value such as `unknown_visitor`. - * This should be the same identifier as - * UserEvent.user_pseudo_id google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id - * and - * CompleteQueryRequest.user_pseudo_id google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - */ - // const userPseudoId = 'abc123' - /** - * The content search spec that configs the desired behavior of content - * search. - */ - // const contentSearchSpec = {} - /** - * Whether to turn on safe search. This is only supported for - * ContentConfig.PUBLIC_WEBSITE . - */ - // const safeSearch = true - /** - * The user 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 userLabels = 1234 - - // Imports the Discoveryengine library - const {SearchServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new SearchServiceClient(); - - async function callSearch() { - // Construct request - const request = { - servingConfig, - }; - - // Run request - const iterable = await discoveryengineClient.searchAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearch(); - // [END discoveryengine_v1_generated_SearchService_Search_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/snippet_metadata.google.cloud.discoveryengine.v1.json b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/snippet_metadata.google.cloud.discoveryengine.v1.json deleted file mode 100644 index 5063fe7ede9..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/snippet_metadata.google.cloud.discoveryengine.v1.json +++ /dev/null @@ -1,867 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-discoveryengine", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.discoveryengine.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "discoveryengine_v1_generated_CompletionService_CompleteQuery_async", - "title": "CompletionService completeQuery Sample", - "origin": "API_DEFINITION", - "description": " Completes the specified user input with keyword suggestions.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 91, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.discoveryengine.v1.CompletionService.CompleteQuery", - "async": true, - "parameters": [ - { - "name": "data_store", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "query_model", - "type": "TYPE_STRING" - }, - { - "name": "user_pseudo_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1.CompleteQueryResponse", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.discoveryengine.v1.CompletionServiceClient" - }, - "method": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.discoveryengine.v1.CompletionService.CompleteQuery", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.discoveryengine.v1.CompletionService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_DocumentService_GetDocument_async", - "title": "CompletionService getDocument Sample", - "origin": "API_DEFINITION", - "description": " Gets a [Document][google.cloud.discoveryengine.v1.Document].", - "canonical": true, - "file": "document_service.get_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDocument", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.GetDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1.Document", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" - }, - "method": { - "shortName": "GetDocument", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.GetDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_DocumentService_ListDocuments_async", - "title": "CompletionService listDocuments Sample", - "origin": "API_DEFINITION", - "description": " Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s.", - "canonical": true, - "file": "document_service.list_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 80, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListDocuments", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.ListDocuments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1.ListDocumentsResponse", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" - }, - "method": { - "shortName": "ListDocuments", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.ListDocuments", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_DocumentService_CreateDocument_async", - "title": "CompletionService createDocument Sample", - "origin": "API_DEFINITION", - "description": " Creates a [Document][google.cloud.discoveryengine.v1.Document].", - "canonical": true, - "file": "document_service.create_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 78, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDocument", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.CreateDocument", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "document", - "type": ".google.cloud.discoveryengine.v1.Document" - }, - { - "name": "document_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1.Document", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" - }, - "method": { - "shortName": "CreateDocument", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.CreateDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_DocumentService_UpdateDocument_async", - "title": "CompletionService updateDocument Sample", - "origin": "API_DEFINITION", - "description": " Updates a [Document][google.cloud.discoveryengine.v1.Document].", - "canonical": true, - "file": "document_service.update_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateDocument", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.UpdateDocument", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.discoveryengine.v1.Document" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.discoveryengine.v1.Document", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" - }, - "method": { - "shortName": "UpdateDocument", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.UpdateDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_DocumentService_DeleteDocument_async", - "title": "CompletionService deleteDocument Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [Document][google.cloud.discoveryengine.v1.Document].", - "canonical": true, - "file": "document_service.delete_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteDocument", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.DeleteDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" - }, - "method": { - "shortName": "DeleteDocument", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.DeleteDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_DocumentService_ImportDocuments_async", - "title": "CompletionService importDocuments Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of multiple [Document][google.cloud.discoveryengine.v1.Document]s. Request processing may be synchronous. Non-existing items will be created. Note: It is possible for a subset of the [Document][google.cloud.discoveryengine.v1.Document]s to be successfully updated.", - "canonical": true, - "file": "document_service.import_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 125, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportDocuments", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.ImportDocuments", - "async": true, - "parameters": [ - { - "name": "inline_source", - "type": ".google.cloud.discoveryengine.v1.ImportDocumentsRequest.InlineSource" - }, - { - "name": "gcs_source", - "type": ".google.cloud.discoveryengine.v1.GcsSource" - }, - { - "name": "bigquery_source", - "type": ".google.cloud.discoveryengine.v1.BigQuerySource" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "error_config", - "type": ".google.cloud.discoveryengine.v1.ImportErrorConfig" - }, - { - "name": "reconciliation_mode", - "type": ".google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode" - }, - { - "name": "auto_generate_ids", - "type": "TYPE_BOOL" - }, - { - "name": "id_field", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" - }, - "method": { - "shortName": "ImportDocuments", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.ImportDocuments", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_DocumentService_PurgeDocuments_async", - "title": "CompletionService purgeDocuments Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes all selected [Document][google.cloud.discoveryengine.v1.Document]s in a branch. This process is asynchronous. Depending on the number of [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this operation can take hours to complete. Before the delete operation completes, some [Document][google.cloud.discoveryengine.v1.Document]s might still be returned by [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] or [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments]. To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, set [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force] to false.", - "canonical": true, - "file": "document_service.purge_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeDocuments", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.PurgeDocuments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1.DocumentServiceClient" - }, - "method": { - "shortName": "PurgeDocuments", - "fullName": "google.cloud.discoveryengine.v1.DocumentService.PurgeDocuments", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_SchemaService_GetSchema_async", - "title": "CompletionService getSchema Sample", - "origin": "API_DEFINITION", - "description": " Gets a [Schema][google.cloud.discoveryengine.v1.Schema].", - "canonical": true, - "file": "schema_service.get_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetSchema", - "fullName": "google.cloud.discoveryengine.v1.SchemaService.GetSchema", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1.Schema", - "client": { - "shortName": "SchemaServiceClient", - "fullName": "google.cloud.discoveryengine.v1.SchemaServiceClient" - }, - "method": { - "shortName": "GetSchema", - "fullName": "google.cloud.discoveryengine.v1.SchemaService.GetSchema", - "service": { - "shortName": "SchemaService", - "fullName": "google.cloud.discoveryengine.v1.SchemaService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_SchemaService_ListSchemas_async", - "title": "CompletionService listSchemas Sample", - "origin": "API_DEFINITION", - "description": " Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s.", - "canonical": true, - "file": "schema_service.list_schemas.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListSchemas", - "fullName": "google.cloud.discoveryengine.v1.SchemaService.ListSchemas", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1.ListSchemasResponse", - "client": { - "shortName": "SchemaServiceClient", - "fullName": "google.cloud.discoveryengine.v1.SchemaServiceClient" - }, - "method": { - "shortName": "ListSchemas", - "fullName": "google.cloud.discoveryengine.v1.SchemaService.ListSchemas", - "service": { - "shortName": "SchemaService", - "fullName": "google.cloud.discoveryengine.v1.SchemaService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_SchemaService_CreateSchema_async", - "title": "CompletionService createSchema Sample", - "origin": "API_DEFINITION", - "description": " Creates a [Schema][google.cloud.discoveryengine.v1.Schema].", - "canonical": true, - "file": "schema_service.create_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateSchema", - "fullName": "google.cloud.discoveryengine.v1.SchemaService.CreateSchema", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "schema", - "type": ".google.cloud.discoveryengine.v1.Schema" - }, - { - "name": "schema_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "SchemaServiceClient", - "fullName": "google.cloud.discoveryengine.v1.SchemaServiceClient" - }, - "method": { - "shortName": "CreateSchema", - "fullName": "google.cloud.discoveryengine.v1.SchemaService.CreateSchema", - "service": { - "shortName": "SchemaService", - "fullName": "google.cloud.discoveryengine.v1.SchemaService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_SchemaService_UpdateSchema_async", - "title": "CompletionService updateSchema Sample", - "origin": "API_DEFINITION", - "description": " Updates a [Schema][google.cloud.discoveryengine.v1.Schema].", - "canonical": true, - "file": "schema_service.update_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateSchema", - "fullName": "google.cloud.discoveryengine.v1.SchemaService.UpdateSchema", - "async": true, - "parameters": [ - { - "name": "schema", - "type": ".google.cloud.discoveryengine.v1.Schema" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "SchemaServiceClient", - "fullName": "google.cloud.discoveryengine.v1.SchemaServiceClient" - }, - "method": { - "shortName": "UpdateSchema", - "fullName": "google.cloud.discoveryengine.v1.SchemaService.UpdateSchema", - "service": { - "shortName": "SchemaService", - "fullName": "google.cloud.discoveryengine.v1.SchemaService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_SchemaService_DeleteSchema_async", - "title": "CompletionService deleteSchema Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [Schema][google.cloud.discoveryengine.v1.Schema].", - "canonical": true, - "file": "schema_service.delete_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteSchema", - "fullName": "google.cloud.discoveryengine.v1.SchemaService.DeleteSchema", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "SchemaServiceClient", - "fullName": "google.cloud.discoveryengine.v1.SchemaServiceClient" - }, - "method": { - "shortName": "DeleteSchema", - "fullName": "google.cloud.discoveryengine.v1.SchemaService.DeleteSchema", - "service": { - "shortName": "SchemaService", - "fullName": "google.cloud.discoveryengine.v1.SchemaService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_SearchService_Search_async", - "title": "CompletionService search Sample", - "origin": "API_DEFINITION", - "description": " Performs a search.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 164, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Search", - "fullName": "google.cloud.discoveryengine.v1.SearchService.Search", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "branch", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "offset", - "type": "TYPE_INT32" - }, - { - "name": "user_info", - "type": ".google.cloud.discoveryengine.v1.UserInfo" - }, - { - "name": "params", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "query_expansion_spec", - "type": ".google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec" - }, - { - "name": "spell_correction_spec", - "type": ".google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec" - }, - { - "name": "user_pseudo_id", - "type": "TYPE_STRING" - }, - { - "name": "content_search_spec", - "type": ".google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec" - }, - { - "name": "safe_search", - "type": "TYPE_BOOL" - }, - { - "name": "user_labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.discoveryengine.v1.SearchResponse", - "client": { - "shortName": "SearchServiceClient", - "fullName": "google.cloud.discoveryengine.v1.SearchServiceClient" - }, - "method": { - "shortName": "Search", - "fullName": "google.cloud.discoveryengine.v1.SearchService.Search", - "service": { - "shortName": "SearchService", - "fullName": "google.cloud.discoveryengine.v1.SearchService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_UserEventService_WriteUserEvent_async", - "title": "CompletionService writeUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event.", - "canonical": true, - "file": "user_event_service.write_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.discoveryengine.v1.UserEventService.WriteUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.discoveryengine.v1.UserEvent" - } - ], - "resultType": ".google.cloud.discoveryengine.v1.UserEvent", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.discoveryengine.v1.UserEventServiceClient" - }, - "method": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.discoveryengine.v1.UserEventService.WriteUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.discoveryengine.v1.UserEventService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_UserEventService_CollectUserEvent_async", - "title": "CompletionService collectUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Discovery Engine API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", - "canonical": true, - "file": "user_event_service.collect_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.discoveryengine.v1.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - } - ], - "resultType": ".google.api.HttpBody", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.discoveryengine.v1.UserEventServiceClient" - }, - "method": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.discoveryengine.v1.UserEventService.CollectUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.discoveryengine.v1.UserEventService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1_generated_UserEventService_ImportUserEvents_async", - "title": "CompletionService importUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", - "canonical": true, - "file": "user_event_service.import_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.discoveryengine.v1.UserEventService.ImportUserEvents", - "async": true, - "parameters": [ - { - "name": "inline_source", - "type": ".google.cloud.discoveryengine.v1.ImportUserEventsRequest.InlineSource" - }, - { - "name": "gcs_source", - "type": ".google.cloud.discoveryengine.v1.GcsSource" - }, - { - "name": "bigquery_source", - "type": ".google.cloud.discoveryengine.v1.BigQuerySource" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "error_config", - "type": ".google.cloud.discoveryengine.v1.ImportErrorConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.discoveryengine.v1.UserEventServiceClient" - }, - "method": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.discoveryengine.v1.UserEventService.ImportUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.discoveryengine.v1.UserEventService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.collect_user_event.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.collect_user_event.js deleted file mode 100644 index 3be0b538b16..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.collect_user_event.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_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 DataStore resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - */ - // 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 Discoveryengine library - const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new UserEventServiceClient(); - - async function callCollectUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await discoveryengineClient.collectUserEvent(request); - console.log(response); - } - - callCollectUserEvent(); - // [END discoveryengine_v1_generated_UserEventService_CollectUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.import_user_events.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.import_user_events.js deleted file mode 100644 index a5e95b91695..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.import_user_events.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2023 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(inlineSource, gcsSource, bigquerySource, parent) { - // [START discoveryengine_v1_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. The Inline source for the input content for UserEvents. - */ - // const inlineSource = {} - /** - * Required. Cloud Storage location for the input content. - */ - // const gcsSource = {} - /** - * Required. BigQuery input source. - */ - // const bigquerySource = {} - /** - * Required. Parent DataStore resource name, of the form - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` - */ - // const parent = 'abc123' - /** - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - */ - // const errorConfig = {} - - // Imports the Discoveryengine library - const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new UserEventServiceClient(); - - async function callImportUserEvents() { - // Construct request - const request = { - inlineSource, - gcsSource, - bigquerySource, - parent, - }; - - // Run request - const [operation] = await discoveryengineClient.importUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportUserEvents(); - // [END discoveryengine_v1_generated_UserEventService_ImportUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.write_user_event.js b/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.write_user_event.js deleted file mode 100644 index c55a9f3aefb..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/samples/generated/v1/user_event_service.write_user_event.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1_generated_UserEventService_WriteUserEvent_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 DataStore resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - - // Imports the Discoveryengine library - const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1; - - // Instantiates a client - const discoveryengineClient = new UserEventServiceClient(); - - async function callWriteUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await discoveryengineClient.writeUserEvent(request); - console.log(response); - } - - callWriteUserEvent(); - // [END discoveryengine_v1_generated_UserEventService_WriteUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/index.ts deleted file mode 100644 index 27888094c09..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 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. ** - -import * as v1 from './v1'; -const CompletionServiceClient = v1.CompletionServiceClient; -type CompletionServiceClient = v1.CompletionServiceClient; -const DocumentServiceClient = v1.DocumentServiceClient; -type DocumentServiceClient = v1.DocumentServiceClient; -const SchemaServiceClient = v1.SchemaServiceClient; -type SchemaServiceClient = v1.SchemaServiceClient; -const SearchServiceClient = v1.SearchServiceClient; -type SearchServiceClient = v1.SearchServiceClient; -const UserEventServiceClient = v1.UserEventServiceClient; -type UserEventServiceClient = v1.UserEventServiceClient; -export {v1, CompletionServiceClient, DocumentServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient}; -export default {v1, CompletionServiceClient, DocumentServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client.ts deleted file mode 100644 index 7e3614d4f77..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client.ts +++ /dev/null @@ -1,854 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/completion_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './completion_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for Auto-Completion. - * @class - * @memberof v1 - */ -export class CompletionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - completionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CompletionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new CompletionServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CompletionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' - ), - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1.CompletionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.completionServiceStub) { - return this.completionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1.CompletionService. - this.completionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1.CompletionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1.CompletionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const completionServiceStubMethods = - ['completeQuery']; - for (const methodName of completionServiceStubMethods) { - const callPromise = this.completionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.completionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Completes the specified user input with keyword suggestions. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.dataStore - * Required. The parent data store resource name for which the completion is - * performed, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store`. - * @param {string} request.query - * Required. The typeahead input used to fetch suggestions. Maximum length is - * 128 characters. - * @param {string} request.queryModel - * Selects data model of query suggestions for serving. Currently supported - * values: - * - * * `document` - Using suggestions generated from user-imported documents. - * * `search-history` - Using suggestions generated from the past history of - * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} - * API calls. Do not use it when there is no traffic for Search API. - * * `user-event` - Using suggestions generated from user-imported search - * events. - * - * Default values: - * - * * `document` is the default model for regular dataStores. - * * `search-history` is the default model for - * {@link google.cloud.discoveryengine.v1.IndustryVertical.SITE_SEARCH|IndustryVertical.SITE_SEARCH} - * dataStores. - * @param {string} request.userPseudoId - * 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. - * - * This field should NOT have a fixed value such as `unknown_visitor`. - * - * This should be the same identifier as - * {@link google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} - * and - * {@link google.cloud.discoveryengine.v1.SearchRequest.user_pseudo_id|SearchRequest.user_pseudo_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.CompleteQueryResponse | CompleteQueryResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/completion_service.complete_query.js - * region_tag:discoveryengine_v1_generated_CompletionService_CompleteQuery_async - */ - completeQuery( - request?: protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|undefined, {}|undefined - ]>; - completeQuery( - request: protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request: protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request?: protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1.ICompleteQueryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'data_store': request.dataStore ?? '', - }); - this.initialize(); - return this.innerApiCalls.completeQuery(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationDataStorePath(project:string,location:string,dataStore:string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.completionServiceStub && !this._terminated) { - return this.completionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client_config.json deleted file mode 100644 index 8cf2b18b202..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_client_config.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1.CompletionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CompleteQuery": { - "timeout_millis": 5000, - "retry_codes_name": "unavailable", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_proto_list.json deleted file mode 100644 index 60d54073cfa..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/completion_service_proto_list.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1/common.proto", - "../../protos/google/cloud/discoveryengine/v1/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1/document.proto", - "../../protos/google/cloud/discoveryengine/v1/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1/schema.proto", - "../../protos/google/cloud/discoveryengine/v1/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client.ts deleted file mode 100644 index a09f0de16be..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client.ts +++ /dev/null @@ -1,1839 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/document_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './document_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting {@link google.cloud.discoveryengine.v1.Document|Document} - * information of the customer's website. - * @class - * @memberof v1 - */ -export class DocumentServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - documentServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DocumentServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new DocumentServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DocumentServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}' - ), - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listDocuments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*}/operations',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*}/operations',},{get: '/v1/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importDocumentsResponse = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.ImportDocumentsResponse') as gax.protobuf.Type; - const importDocumentsMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.ImportDocumentsMetadata') as gax.protobuf.Type; - const purgeDocumentsResponse = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.PurgeDocumentsResponse') as gax.protobuf.Type; - const purgeDocumentsMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.PurgeDocumentsMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importDocumentsResponse.decode.bind(importDocumentsResponse), - importDocumentsMetadata.decode.bind(importDocumentsMetadata)), - purgeDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeDocumentsResponse.decode.bind(purgeDocumentsResponse), - purgeDocumentsMetadata.decode.bind(purgeDocumentsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1.DocumentService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.documentServiceStub) { - return this.documentServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1.DocumentService. - this.documentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1.DocumentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1.DocumentService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const documentServiceStubMethods = - ['getDocument', 'listDocuments', 'createDocument', 'updateDocument', 'deleteDocument', 'importDocuments', 'purgeDocuments']; - for (const methodName of documentServiceStubMethods) { - const callPromise = this.documentServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.documentServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets a {@link google.cloud.discoveryengine.v1.Document|Document}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.discoveryengine.v1.Document|Document}, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - * - * If the caller does not have permission to access the - * {@link google.cloud.discoveryengine.v1.Document|Document}, regardless of whether - * or not it exists, a `PERMISSION_DENIED` error is returned. - * - * If the requested {@link google.cloud.discoveryengine.v1.Document|Document} does - * not exist, a `NOT_FOUND` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.Document | Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_service.get_document.js - * region_tag:discoveryengine_v1_generated_DocumentService_GetDocument_async - */ - getDocument( - request?: protos.google.cloud.discoveryengine.v1.IGetDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|undefined, {}|undefined - ]>; - getDocument( - request: protos.google.cloud.discoveryengine.v1.IGetDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): void; - getDocument( - request: protos.google.cloud.discoveryengine.v1.IGetDocumentRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): void; - getDocument( - request?: protos.google.cloud.discoveryengine.v1.IGetDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IGetDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getDocument(request, options, callback); - } -/** - * Creates a {@link google.cloud.discoveryengine.v1.Document|Document}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * @param {google.cloud.discoveryengine.v1.Document} request.document - * Required. The {@link google.cloud.discoveryengine.v1.Document|Document} to - * create. - * @param {string} request.documentId - * Required. The ID to use for the - * {@link google.cloud.discoveryengine.v1.Document|Document}, which will become the - * final component of the - * {@link google.cloud.discoveryengine.v1.Document.name|Document.name}. - * - * If the caller does not have permission to create the - * {@link google.cloud.discoveryengine.v1.Document|Document}, regardless of whether - * or not it exists, a `PERMISSION_DENIED` error is returned. - * - * This field must be unique among all - * {@link google.cloud.discoveryengine.v1.Document|Document}s with the same - * {@link google.cloud.discoveryengine.v1.CreateDocumentRequest.parent|parent}. - * Otherwise, an `ALREADY_EXISTS` error is returned. - * - * This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) - * standard with a length limit of 63 characters. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.Document | Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_service.create_document.js - * region_tag:discoveryengine_v1_generated_DocumentService_CreateDocument_async - */ - createDocument( - request?: protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|undefined, {}|undefined - ]>; - createDocument( - request: protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): void; - createDocument( - request: protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): void; - createDocument( - request?: protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.ICreateDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createDocument(request, options, callback); - } -/** - * Updates a {@link google.cloud.discoveryengine.v1.Document|Document}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.discoveryengine.v1.Document} request.document - * Required. The document to update/create. - * - * If the caller does not have permission to update the - * {@link google.cloud.discoveryengine.v1.Document|Document}, regardless of whether - * or not it exists, a `PERMISSION_DENIED` error is returned. - * - * If the {@link google.cloud.discoveryengine.v1.Document|Document} to update does - * not exist and - * {@link google.cloud.discoveryengine.v1.UpdateDocumentRequest.allow_missing|allow_missing} - * is not set, a `NOT_FOUND` error is returned. - * @param {boolean} request.allowMissing - * If set to true, and the - * {@link google.cloud.discoveryengine.v1.Document|Document} is not found, a new - * {@link google.cloud.discoveryengine.v1.Document|Document} will be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.Document | Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_service.update_document.js - * region_tag:discoveryengine_v1_generated_DocumentService_UpdateDocument_async - */ - updateDocument( - request?: protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|undefined, {}|undefined - ]>; - updateDocument( - request: protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): void; - updateDocument( - request: protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): void; - updateDocument( - request?: protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1.IDocument, - protos.google.cloud.discoveryengine.v1.IUpdateDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'document.name': request.document!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateDocument(request, options, callback); - } -/** - * Deletes a {@link google.cloud.discoveryengine.v1.Document|Document}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.discoveryengine.v1.Document|Document}, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - * - * If the caller does not have permission to delete the - * {@link google.cloud.discoveryengine.v1.Document|Document}, regardless of whether - * or not it exists, a `PERMISSION_DENIED` error is returned. - * - * If the {@link google.cloud.discoveryengine.v1.Document|Document} to delete does - * not exist, a `NOT_FOUND` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.protobuf.Empty | Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_service.delete_document.js - * region_tag:discoveryengine_v1_generated_DocumentService_DeleteDocument_async - */ - deleteDocument( - request?: protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|undefined, {}|undefined - ]>; - deleteDocument( - request: protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): void; - deleteDocument( - request: protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): void; - deleteDocument( - request?: protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1.IDeleteDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteDocument(request, options, callback); - } - -/** - * Bulk import of multiple - * {@link google.cloud.discoveryengine.v1.Document|Document}s. Request processing - * may be synchronous. Non-existing items will be created. - * - * Note: It is possible for a subset of the - * {@link google.cloud.discoveryengine.v1.Document|Document}s to be successfully - * updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.discoveryengine.v1.ImportDocumentsRequest.InlineSource} request.inlineSource - * The Inline source for the input content for documents. - * @param {google.cloud.discoveryengine.v1.GcsSource} request.gcsSource - * Cloud Storage location for the input content. - * @param {google.cloud.discoveryengine.v1.BigQuerySource} request.bigquerySource - * BigQuery input source. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Requires create/update permission. - * @param {google.cloud.discoveryengine.v1.ImportErrorConfig} request.errorConfig - * The desired location of errors incurred during the Import. - * @param {google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode} request.reconciliationMode - * The mode of reconciliation between existing documents and the documents to - * be imported. Defaults to - * {@link google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. - * @param {boolean} request.autoGenerateIds - * Whether to automatically generate IDs for the documents if absent. - * - * If set to `true`, - * {@link google.cloud.discoveryengine.v1.Document.id|Document.id}s are - * automatically generated based on the hash of the payload, where IDs may not - * be consistent during multiple imports. In which case - * {@link google.cloud.discoveryengine.v1.ImportDocumentsRequest.ReconciliationMode.FULL|ReconciliationMode.FULL} - * is highly recommended to avoid duplicate contents. If unset or set to - * `false`, {@link google.cloud.discoveryengine.v1.Document.id|Document.id}s have - * to be specified using - * {@link google.cloud.discoveryengine.v1.ImportDocumentsRequest.id_field|id_field}, - * otherwises, documents without IDs will fail to be imported. - * - * Only set this field when using - * {@link google.cloud.discoveryengine.v1.GcsSource|GcsSource} or - * {@link google.cloud.discoveryengine.v1.BigQuerySource|BigQuerySource}, and when - * {@link google.cloud.discoveryengine.v1.GcsSource.data_schema|GcsSource.data_schema} - * or - * {@link google.cloud.discoveryengine.v1.BigQuerySource.data_schema|BigQuerySource.data_schema} - * is `custom`. Otherwise, an INVALID_ARGUMENT error is thrown. - * @param {string} request.idField - * The field in the Cloud Storage and BigQuery sources that indicates the - * unique IDs of the documents. - * - * For {@link google.cloud.discoveryengine.v1.GcsSource|GcsSource} it is the key of - * the JSON field. For instance, `my_id` for JSON `{"my_id": "some_uuid"}`. - * For {@link google.cloud.discoveryengine.v1.BigQuerySource|BigQuerySource} it is - * the column name of the BigQuery table where the unique ids are stored. - * - * The values of the JSON field or the BigQuery column will be used as the - * {@link google.cloud.discoveryengine.v1.Document.id|Document.id}s. The JSON field - * or the BigQuery column must be of string type, and the values must be set - * as valid strings conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) - * with 1-63 characters. Otherwise, documents without valid IDs will fail to - * be imported. - * - * Only set this field when using - * {@link google.cloud.discoveryengine.v1.GcsSource|GcsSource} or - * {@link google.cloud.discoveryengine.v1.BigQuerySource|BigQuerySource}, and when - * {@link google.cloud.discoveryengine.v1.GcsSource.data_schema|GcsSource.data_schema} - * or - * {@link google.cloud.discoveryengine.v1.BigQuerySource.data_schema|BigQuerySource.data_schema} - * is `custom`. And only set this field when - * {@link google.cloud.discoveryengine.v1.ImportDocumentsRequest.auto_generate_ids|auto_generate_ids} - * is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. - * - * If it is unset, a default value `_id` is used when importing from the - * allowed data sources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_service.import_documents.js - * region_tag:discoveryengine_v1_generated_DocumentService_ImportDocuments_async - */ - importDocuments( - request?: protos.google.cloud.discoveryengine.v1.IImportDocumentsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importDocuments( - request: protos.google.cloud.discoveryengine.v1.IImportDocumentsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importDocuments( - request: protos.google.cloud.discoveryengine.v1.IImportDocumentsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importDocuments( - request?: protos.google.cloud.discoveryengine.v1.IImportDocumentsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.importDocuments(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importDocuments()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_service.import_documents.js - * region_tag:discoveryengine_v1_generated_DocumentService_ImportDocuments_async - */ - async checkImportDocumentsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importDocuments, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Permanently deletes all selected - * {@link google.cloud.discoveryengine.v1.Document|Document}s in a branch. - * - * This process is asynchronous. Depending on the number of - * {@link google.cloud.discoveryengine.v1.Document|Document}s to be deleted, this - * operation can take hours to complete. Before the delete operation - * completes, some {@link google.cloud.discoveryengine.v1.Document|Document}s might - * still be returned by - * {@link google.cloud.discoveryengine.v1.DocumentService.GetDocument|DocumentService.GetDocument} - * or - * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments}. - * - * To get a list of the {@link google.cloud.discoveryengine.v1.Document|Document}s - * to be deleted, set - * {@link google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force|PurgeDocumentsRequest.force} - * to false. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * @param {string} request.filter - * Required. Filter matching documents to purge. Only currently supported - * value is - * `*` (all items). - * @param {boolean} request.force - * Actually performs the purge. If `force` is set to false, return the - * expected purge count without deleting any documents. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_service.purge_documents.js - * region_tag:discoveryengine_v1_generated_DocumentService_PurgeDocuments_async - */ - purgeDocuments( - request?: protos.google.cloud.discoveryengine.v1.IPurgeDocumentsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeDocuments( - request: protos.google.cloud.discoveryengine.v1.IPurgeDocumentsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeDocuments( - request: protos.google.cloud.discoveryengine.v1.IPurgeDocumentsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeDocuments( - request?: protos.google.cloud.discoveryengine.v1.IPurgeDocumentsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.purgeDocuments(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeDocuments()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_service.purge_documents.js - * region_tag:discoveryengine_v1_generated_DocumentService_PurgeDocuments_async - */ - async checkPurgeDocumentsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeDocuments, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Gets a list of {@link google.cloud.discoveryengine.v1.Document|Document}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Use `default_branch` as the branch ID, to list documents under the default - * branch. - * - * If the caller does not have permission to list {@link |Documents}s under this - * branch, regardless of whether or not this branch exists, a - * `PERMISSION_DENIED` error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}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. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.discoveryengine.v1.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link google.cloud.discoveryengine.v1.Document | Document}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDocumentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDocuments( - request?: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1.IDocument[], - protos.google.cloud.discoveryengine.v1.IListDocumentsRequest|null, - protos.google.cloud.discoveryengine.v1.IListDocumentsResponse - ]>; - listDocuments( - request: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, - protos.google.cloud.discoveryengine.v1.IListDocumentsResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.IDocument>): void; - listDocuments( - request: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, - protos.google.cloud.discoveryengine.v1.IListDocumentsResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.IDocument>): void; - listDocuments( - request?: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, - protos.google.cloud.discoveryengine.v1.IListDocumentsResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.IDocument>, - callback?: PaginationCallback< - protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, - protos.google.cloud.discoveryengine.v1.IListDocumentsResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.IDocument>): - Promise<[ - protos.google.cloud.discoveryengine.v1.IDocument[], - protos.google.cloud.discoveryengine.v1.IListDocumentsRequest|null, - protos.google.cloud.discoveryengine.v1.IListDocumentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listDocuments(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Use `default_branch` as the branch ID, to list documents under the default - * branch. - * - * If the caller does not have permission to list {@link |Documents}s under this - * branch, regardless of whether or not this branch exists, a - * `PERMISSION_DENIED` error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}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. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.discoveryengine.v1.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1.Document | Document} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDocumentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDocumentsStream( - request?: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.createStream( - this.innerApiCalls.listDocuments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listDocuments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Use `default_branch` as the branch ID, to list documents under the default - * branch. - * - * If the caller does not have permission to list {@link |Documents}s under this - * branch, regardless of whether or not this branch exists, a - * `PERMISSION_DENIED` error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}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. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.discoveryengine.v1.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1.DocumentService.ListDocuments|DocumentService.ListDocuments} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.discoveryengine.v1.Document | Document}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/document_service.list_documents.js - * region_tag:discoveryengine_v1_generated_DocumentService_ListDocuments_async - */ - listDocumentsAsync( - request?: protos.google.cloud.discoveryengine.v1.IListDocumentsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.asyncIterate( - this.innerApiCalls['listDocuments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchPath(project:string,location:string,collection:string,dataStore:string,branch:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).branch; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchPath(project:string,location:string,dataStore:string,branch:string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).branch; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.documentServiceStub && !this._terminated) { - return this.documentServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client_config.json deleted file mode 100644 index cb11ed6b90a..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_client_config.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1.DocumentService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "GetDocument": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListDocuments": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "CreateDocument": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateDocument": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "DeleteDocument": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ImportDocuments": { - "timeout_millis": 300000, - "retry_codes_name": "unavailable", - "retry_params_name": "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876" - }, - "PurgeDocuments": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_proto_list.json deleted file mode 100644 index 60d54073cfa..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/document_service_proto_list.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1/common.proto", - "../../protos/google/cloud/discoveryengine/v1/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1/document.proto", - "../../protos/google/cloud/discoveryengine/v1/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1/schema.proto", - "../../protos/google/cloud/discoveryengine/v1/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 4ca67f3204b..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,261 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.discoveryengine.v1", - "libraryPackage": "@google-cloud/discoveryengine", - "services": { - "CompletionService": { - "clients": { - "grpc": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - } - } - } - } - }, - "DocumentService": { - "clients": { - "grpc": { - "libraryClient": "DocumentServiceClient", - "rpcs": { - "GetDocument": { - "methods": [ - "getDocument" - ] - }, - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, - "UpdateDocument": { - "methods": [ - "updateDocument" - ] - }, - "DeleteDocument": { - "methods": [ - "deleteDocument" - ] - }, - "ImportDocuments": { - "methods": [ - "importDocuments" - ] - }, - "PurgeDocuments": { - "methods": [ - "purgeDocuments" - ] - }, - "ListDocuments": { - "methods": [ - "listDocuments", - "listDocumentsStream", - "listDocumentsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentServiceClient", - "rpcs": { - "GetDocument": { - "methods": [ - "getDocument" - ] - }, - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, - "UpdateDocument": { - "methods": [ - "updateDocument" - ] - }, - "DeleteDocument": { - "methods": [ - "deleteDocument" - ] - }, - "ImportDocuments": { - "methods": [ - "importDocuments" - ] - }, - "PurgeDocuments": { - "methods": [ - "purgeDocuments" - ] - }, - "ListDocuments": { - "methods": [ - "listDocuments", - "listDocumentsStream", - "listDocumentsAsync" - ] - } - } - } - } - }, - "SchemaService": { - "clients": { - "grpc": { - "libraryClient": "SchemaServiceClient", - "rpcs": { - "GetSchema": { - "methods": [ - "getSchema" - ] - }, - "CreateSchema": { - "methods": [ - "createSchema" - ] - }, - "UpdateSchema": { - "methods": [ - "updateSchema" - ] - }, - "DeleteSchema": { - "methods": [ - "deleteSchema" - ] - }, - "ListSchemas": { - "methods": [ - "listSchemas", - "listSchemasStream", - "listSchemasAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SchemaServiceClient", - "rpcs": { - "GetSchema": { - "methods": [ - "getSchema" - ] - }, - "CreateSchema": { - "methods": [ - "createSchema" - ] - }, - "UpdateSchema": { - "methods": [ - "updateSchema" - ] - }, - "DeleteSchema": { - "methods": [ - "deleteSchema" - ] - }, - "ListSchemas": { - "methods": [ - "listSchemas", - "listSchemasStream", - "listSchemasAsync" - ] - } - } - } - } - }, - "SearchService": { - "clients": { - "grpc": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - } - } - }, - "UserEventService": { - "clients": { - "grpc": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/index.ts deleted file mode 100644 index ecca0c5d193..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2023 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. ** - -export {CompletionServiceClient} from './completion_service_client'; -export {DocumentServiceClient} from './document_service_client'; -export {SchemaServiceClient} from './schema_service_client'; -export {SearchServiceClient} from './search_service_client'; -export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client.ts deleted file mode 100644 index 6c475dd0ec3..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client.ts +++ /dev/null @@ -1,1550 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/schema_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './schema_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for managing {@link google.cloud.discoveryengine.v1.Schema|Schema}s. - * @class - * @memberof v1 - */ -export class SchemaServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - schemaServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SchemaServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new SchemaServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SchemaServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' - ), - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listSchemas: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'schemas') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*}/operations',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*}/operations',},{get: '/v1/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createSchemaResponse = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.Schema') as gax.protobuf.Type; - const createSchemaMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.CreateSchemaMetadata') as gax.protobuf.Type; - const updateSchemaResponse = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.Schema') as gax.protobuf.Type; - const updateSchemaMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.UpdateSchemaMetadata') as gax.protobuf.Type; - const deleteSchemaResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteSchemaMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.DeleteSchemaMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createSchema: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createSchemaResponse.decode.bind(createSchemaResponse), - createSchemaMetadata.decode.bind(createSchemaMetadata)), - updateSchema: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateSchemaResponse.decode.bind(updateSchemaResponse), - updateSchemaMetadata.decode.bind(updateSchemaMetadata)), - deleteSchema: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteSchemaResponse.decode.bind(deleteSchemaResponse), - deleteSchemaMetadata.decode.bind(deleteSchemaMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1.SchemaService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.schemaServiceStub) { - return this.schemaServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1.SchemaService. - this.schemaServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1.SchemaService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1.SchemaService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const schemaServiceStubMethods = - ['getSchema', 'listSchemas', 'createSchema', 'updateSchema', 'deleteSchema']; - for (const methodName of schemaServiceStubMethods) { - const callPromise = this.schemaServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.schemaServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets a {@link google.cloud.discoveryengine.v1.Schema|Schema}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full resource name of the schema, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.Schema | Schema}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/schema_service.get_schema.js - * region_tag:discoveryengine_v1_generated_SchemaService_GetSchema_async - */ - getSchema( - request?: protos.google.cloud.discoveryengine.v1.IGetSchemaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1.ISchema, - protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|undefined, {}|undefined - ]>; - getSchema( - request: protos.google.cloud.discoveryengine.v1.IGetSchemaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1.ISchema, - protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|null|undefined, - {}|null|undefined>): void; - getSchema( - request: protos.google.cloud.discoveryengine.v1.IGetSchemaRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1.ISchema, - protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|null|undefined, - {}|null|undefined>): void; - getSchema( - request?: protos.google.cloud.discoveryengine.v1.IGetSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1.ISchema, - protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1.ISchema, - protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1.ISchema, - protos.google.cloud.discoveryengine.v1.IGetSchemaRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getSchema(request, options, callback); - } - -/** - * Creates a {@link google.cloud.discoveryengine.v1.Schema|Schema}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {google.cloud.discoveryengine.v1.Schema} request.schema - * Required. The {@link google.cloud.discoveryengine.v1.Schema|Schema} to create. - * @param {string} request.schemaId - * Required. The ID to use for the - * {@link google.cloud.discoveryengine.v1.Schema|Schema}, which will become the - * final component of the - * {@link google.cloud.discoveryengine.v1.Schema.name|Schema.name}. - * - * This field should conform to - * [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length - * limit of 63 characters. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/schema_service.create_schema.js - * region_tag:discoveryengine_v1_generated_SchemaService_CreateSchema_async - */ - createSchema( - request?: protos.google.cloud.discoveryengine.v1.ICreateSchemaRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createSchema( - request: protos.google.cloud.discoveryengine.v1.ICreateSchemaRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createSchema( - request: protos.google.cloud.discoveryengine.v1.ICreateSchemaRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createSchema( - request?: protos.google.cloud.discoveryengine.v1.ICreateSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createSchema(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createSchema()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/schema_service.create_schema.js - * region_tag:discoveryengine_v1_generated_SchemaService_CreateSchema_async - */ - async checkCreateSchemaProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createSchema, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a {@link google.cloud.discoveryengine.v1.Schema|Schema}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.discoveryengine.v1.Schema} request.schema - * Required. The {@link google.cloud.discoveryengine.v1.Schema|Schema} to update. - * @param {boolean} request.allowMissing - * If set to true, and the {@link google.cloud.discoveryengine.v1.Schema|Schema} is - * not found, a new {@link google.cloud.discoveryengine.v1.Schema|Schema} will be - * created. In this situation, `update_mask` is ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/schema_service.update_schema.js - * region_tag:discoveryengine_v1_generated_SchemaService_UpdateSchema_async - */ - updateSchema( - request?: protos.google.cloud.discoveryengine.v1.IUpdateSchemaRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateSchema( - request: protos.google.cloud.discoveryengine.v1.IUpdateSchemaRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateSchema( - request: protos.google.cloud.discoveryengine.v1.IUpdateSchemaRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateSchema( - request?: protos.google.cloud.discoveryengine.v1.IUpdateSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'schema.name': request.schema!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateSchema(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateSchema()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/schema_service.update_schema.js - * region_tag:discoveryengine_v1_generated_SchemaService_UpdateSchema_async - */ - async checkUpdateSchemaProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateSchema, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a {@link google.cloud.discoveryengine.v1.Schema|Schema}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full resource name of the schema, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/schema_service.delete_schema.js - * region_tag:discoveryengine_v1_generated_SchemaService_DeleteSchema_async - */ - deleteSchema( - request?: protos.google.cloud.discoveryengine.v1.IDeleteSchemaRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteSchema( - request: protos.google.cloud.discoveryengine.v1.IDeleteSchemaRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteSchema( - request: protos.google.cloud.discoveryengine.v1.IDeleteSchemaRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteSchema( - request?: protos.google.cloud.discoveryengine.v1.IDeleteSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteSchema(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteSchema()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/schema_service.delete_schema.js - * region_tag:discoveryengine_v1_generated_SchemaService_DeleteSchema_async - */ - async checkDeleteSchemaProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteSchema, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Gets a list of {@link google.cloud.discoveryengine.v1.Schema|Schema}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {number} request.pageSize - * The maximum number of {@link google.cloud.discoveryengine.v1.Schema|Schema}s to - * return. The service may return fewer than this value. - * - * If unspecified, at most 100 - * {@link google.cloud.discoveryengine.v1.Schema|Schema}s will be returned. - * - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} - * must match the call that provided the page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link google.cloud.discoveryengine.v1.Schema | Schema}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSchemasAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listSchemas( - request?: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1.ISchema[], - protos.google.cloud.discoveryengine.v1.IListSchemasRequest|null, - protos.google.cloud.discoveryengine.v1.IListSchemasResponse - ]>; - listSchemas( - request: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1.IListSchemasRequest, - protos.google.cloud.discoveryengine.v1.IListSchemasResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.ISchema>): void; - listSchemas( - request: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1.IListSchemasRequest, - protos.google.cloud.discoveryengine.v1.IListSchemasResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.ISchema>): void; - listSchemas( - request?: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.discoveryengine.v1.IListSchemasRequest, - protos.google.cloud.discoveryengine.v1.IListSchemasResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.ISchema>, - callback?: PaginationCallback< - protos.google.cloud.discoveryengine.v1.IListSchemasRequest, - protos.google.cloud.discoveryengine.v1.IListSchemasResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.ISchema>): - Promise<[ - protos.google.cloud.discoveryengine.v1.ISchema[], - protos.google.cloud.discoveryengine.v1.IListSchemasRequest|null, - protos.google.cloud.discoveryengine.v1.IListSchemasResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listSchemas(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {number} request.pageSize - * The maximum number of {@link google.cloud.discoveryengine.v1.Schema|Schema}s to - * return. The service may return fewer than this value. - * - * If unspecified, at most 100 - * {@link google.cloud.discoveryengine.v1.Schema|Schema}s will be returned. - * - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} - * must match the call that provided the page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1.Schema | Schema} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSchemasAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listSchemasStream( - request?: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listSchemas']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSchemas.createStream( - this.innerApiCalls.listSchemas as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listSchemas`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {number} request.pageSize - * The maximum number of {@link google.cloud.discoveryengine.v1.Schema|Schema}s to - * return. The service may return fewer than this value. - * - * If unspecified, at most 100 - * {@link google.cloud.discoveryengine.v1.Schema|Schema}s will be returned. - * - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1.SchemaService.ListSchemas|SchemaService.ListSchemas} - * must match the call that provided the page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.discoveryengine.v1.Schema | Schema}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/schema_service.list_schemas.js - * region_tag:discoveryengine_v1_generated_SchemaService_ListSchemas_async - */ - listSchemasAsync( - request?: protos.google.cloud.discoveryengine.v1.IListSchemasRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listSchemas']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSchemas.asyncIterate( - this.innerApiCalls['listSchemas'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationDataStorePath(project:string,location:string,dataStore:string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.schemaServiceStub && !this._terminated) { - return this.schemaServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client_config.json deleted file mode 100644 index 3f6973aed28..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_client_config.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1.SchemaService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "GetSchema": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListSchemas": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "CreateSchema": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateSchema": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "DeleteSchema": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_proto_list.json deleted file mode 100644 index 60d54073cfa..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/schema_service_proto_list.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1/common.proto", - "../../protos/google/cloud/discoveryengine/v1/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1/document.proto", - "../../protos/google/cloud/discoveryengine/v1/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1/schema.proto", - "../../protos/google/cloud/discoveryengine/v1/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client.ts deleted file mode 100644 index c4b9d426e03..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client.ts +++ /dev/null @@ -1,1367 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/search_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './search_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for search. - * @class - * @memberof v1 - */ -export class SearchServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - searchServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SearchServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new SearchServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SearchServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}' - ), - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationCollectionDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}' - ), - projectLocationDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - search: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1.SearchService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.searchServiceStub) { - return this.searchServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1.SearchService. - this.searchServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1.SearchService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1.SearchService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const searchServiceStubMethods = - ['search']; - for (const methodName of searchServiceStubMethods) { - const callPromise = this.searchServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.searchServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Performs a search. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The resource name of the Search serving config, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. - * This field is used to identify the serving configuration name, set - * of models used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. - * - * Use `default_branch` as the branch ID or leave this field empty, to search - * documents under the default branch. - * @param {string} request.query - * Raw search query. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 100. Values above 100 will be coerced to 100. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {string} request.pageToken - * A page token received from a previous - * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.discoveryengine.v1.Document|Document}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link google.cloud.discoveryengine.v1.SearchRequest.page_token|page_token} is - * unset. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {google.cloud.discoveryengine.v1.UserInfo} request.userInfo - * Information about the end user. - * Highly recommended for analytics. The user_agent string in UserInfo will - * be used to deduce device_type for analytics. - * @param {number[]} request.params - * Additional search parameters. - * - * For public website search only, supported values are: - * - * * `user_country_code`: string. Default empty. If set to non-empty, results - * are restricted or boosted based on the location provided. - * * `search_type`: double. Default empty. Enables non-webpage searching - * depending on the value. The only valid non-default value is 1, - * which enables image searching. - * @param {google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. - * @param {google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.userPseudoId - * 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. - * - * This field should NOT have a fixed value such as `unknown_visitor`. - * - * This should be the same identifier as - * {@link google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} - * and - * {@link google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - * @param {google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec} request.contentSearchSpec - * The content search spec that configs the desired behavior of content - * search. - * @param {boolean} request.safeSearch - * Whether to turn on safe search. This is only supported for - * {@link |ContentConfig.PUBLIC_WEBSITE}. - * @param {number[]} request.userLabels - * The user 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. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link google.cloud.discoveryengine.v1.SearchResponse.SearchResult | SearchResult}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - search( - request?: protos.google.cloud.discoveryengine.v1.ISearchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult[], - protos.google.cloud.discoveryengine.v1.ISearchRequest|null, - protos.google.cloud.discoveryengine.v1.ISearchResponse - ]>; - search( - request: protos.google.cloud.discoveryengine.v1.ISearchRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1.ISearchRequest, - protos.google.cloud.discoveryengine.v1.ISearchResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult>): void; - search( - request: protos.google.cloud.discoveryengine.v1.ISearchRequest, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1.ISearchRequest, - protos.google.cloud.discoveryengine.v1.ISearchResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult>): void; - search( - request?: protos.google.cloud.discoveryengine.v1.ISearchRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.discoveryengine.v1.ISearchRequest, - protos.google.cloud.discoveryengine.v1.ISearchResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult>, - callback?: PaginationCallback< - protos.google.cloud.discoveryengine.v1.ISearchRequest, - protos.google.cloud.discoveryengine.v1.ISearchResponse|null|undefined, - protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult>): - Promise<[ - protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult[], - protos.google.cloud.discoveryengine.v1.ISearchRequest|null, - protos.google.cloud.discoveryengine.v1.ISearchResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'serving_config': request.servingConfig ?? '', - }); - this.initialize(); - return this.innerApiCalls.search(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The resource name of the Search serving config, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. - * This field is used to identify the serving configuration name, set - * of models used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. - * - * Use `default_branch` as the branch ID or leave this field empty, to search - * documents under the default branch. - * @param {string} request.query - * Raw search query. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 100. Values above 100 will be coerced to 100. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {string} request.pageToken - * A page token received from a previous - * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.discoveryengine.v1.Document|Document}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link google.cloud.discoveryengine.v1.SearchRequest.page_token|page_token} is - * unset. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {google.cloud.discoveryengine.v1.UserInfo} request.userInfo - * Information about the end user. - * Highly recommended for analytics. The user_agent string in UserInfo will - * be used to deduce device_type for analytics. - * @param {number[]} request.params - * Additional search parameters. - * - * For public website search only, supported values are: - * - * * `user_country_code`: string. Default empty. If set to non-empty, results - * are restricted or boosted based on the location provided. - * * `search_type`: double. Default empty. Enables non-webpage searching - * depending on the value. The only valid non-default value is 1, - * which enables image searching. - * @param {google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. - * @param {google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.userPseudoId - * 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. - * - * This field should NOT have a fixed value such as `unknown_visitor`. - * - * This should be the same identifier as - * {@link google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} - * and - * {@link google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - * @param {google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec} request.contentSearchSpec - * The content search spec that configs the desired behavior of content - * search. - * @param {boolean} request.safeSearch - * Whether to turn on safe search. This is only supported for - * {@link |ContentConfig.PUBLIC_WEBSITE}. - * @param {number[]} request.userLabels - * The user 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. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1.SearchResponse.SearchResult | SearchResult} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - searchStream( - request?: protos.google.cloud.discoveryengine.v1.ISearchRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'serving_config': request.servingConfig ?? '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.createStream( - this.innerApiCalls.search as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `search`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The resource name of the Search serving config, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. - * This field is used to identify the serving configuration name, set - * of models used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. - * - * Use `default_branch` as the branch ID or leave this field empty, to search - * documents under the default branch. - * @param {string} request.query - * Raw search query. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1.Document|Document}s to - * return. If unspecified, defaults to a reasonable value. The maximum allowed - * value is 100. Values above 100 will be coerced to 100. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {string} request.pageToken - * A page token received from a previous - * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.discoveryengine.v1.Document|Document}s deemed by the API as - * relevant) in search results. This field is only considered if - * {@link google.cloud.discoveryengine.v1.SearchRequest.page_token|page_token} is - * unset. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {google.cloud.discoveryengine.v1.UserInfo} request.userInfo - * Information about the end user. - * Highly recommended for analytics. The user_agent string in UserInfo will - * be used to deduce device_type for analytics. - * @param {number[]} request.params - * Additional search parameters. - * - * For public website search only, supported values are: - * - * * `user_country_code`: string. Default empty. If set to non-empty, results - * are restricted or boosted based on the location provided. - * * `search_type`: double. Default empty. Enables non-webpage searching - * depending on the value. The only valid non-default value is 1, - * which enables image searching. - * @param {google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. - * @param {google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.userPseudoId - * 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. - * - * This field should NOT have a fixed value such as `unknown_visitor`. - * - * This should be the same identifier as - * {@link google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} - * and - * {@link google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - * @param {google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec} request.contentSearchSpec - * The content search spec that configs the desired behavior of content - * search. - * @param {boolean} request.safeSearch - * Whether to turn on safe search. This is only supported for - * {@link |ContentConfig.PUBLIC_WEBSITE}. - * @param {number[]} request.userLabels - * The user 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. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.discoveryengine.v1.SearchResponse.SearchResult | SearchResult}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/search_service.search.js - * region_tag:discoveryengine_v1_generated_SearchService_Search_async - */ - searchAsync( - request?: protos.google.cloud.discoveryengine.v1.ISearchRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'serving_config': request.servingConfig ?? '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.asyncIterate( - this.innerApiCalls['search'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchPath(project:string,location:string,collection:string,dataStore:string,branch:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).branch; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreServingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} serving_config - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreServingConfigPath(project:string,location:string,collection:string,dataStore:string,servingConfig:string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).data_store; - } - - /** - * Parse the serving_config from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).serving_config; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchPath(project:string,location:string,dataStore:string,branch:string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).branch; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStoreServingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} serving_config - * @returns {string} Resource name string. - */ - projectLocationDataStoreServingConfigPath(project:string,location:string,dataStore:string,servingConfig:string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).data_store; - } - - /** - * Parse the serving_config from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.searchServiceStub && !this._terminated) { - return this.searchServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client_config.json deleted file mode 100644 index a923eb634aa..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_client_config.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1.SearchService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Search": { - "timeout_millis": 5000, - "retry_codes_name": "unavailable", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_proto_list.json deleted file mode 100644 index 60d54073cfa..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/search_service_proto_list.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1/common.proto", - "../../protos/google/cloud/discoveryengine/v1/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1/document.proto", - "../../protos/google/cloud/discoveryengine/v1/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1/schema.proto", - "../../protos/google/cloud/discoveryengine/v1/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client.ts deleted file mode 100644 index c025349428b..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client.ts +++ /dev/null @@ -1,1220 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/user_event_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './user_event_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting end user actions on a website to Discovery Engine API. - * @class - * @memberof v1 - */ -export class UserEventServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - userEventServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of UserEventServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new UserEventServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof UserEventServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' - ), - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/v1/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*}/operations',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1/{name=projects/*/locations/*}/operations',},{get: '/v1/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.ImportUserEventsResponse') as gax.protobuf.Type; - const importUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1.ImportUserEventsMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importUserEventsResponse.decode.bind(importUserEventsResponse), - importUserEventsMetadata.decode.bind(importUserEventsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1.UserEventService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.userEventServiceStub) { - return this.userEventServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1.UserEventService. - this.userEventServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1.UserEventService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1.UserEventService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const userEventServiceStubMethods = - ['writeUserEvent', 'collectUserEvent', 'importUserEvents']; - for (const methodName of userEventServiceStubMethods) { - const callPromise = this.userEventServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.userEventServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Writes a single user event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent DataStore resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {google.cloud.discoveryengine.v1.UserEvent} request.userEvent - * Required. User event to write. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1.UserEvent | UserEvent}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/user_event_service.write_user_event.js - * region_tag:discoveryengine_v1_generated_UserEventService_WriteUserEvent_async - */ - writeUserEvent( - request?: protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1.IUserEvent, - protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|undefined, {}|undefined - ]>; - writeUserEvent( - request: protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1.IUserEvent, - protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request: protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1.IUserEvent, - protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request?: protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1.IUserEvent, - protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1.IUserEvent, - protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1.IUserEvent, - protos.google.cloud.discoveryengine.v1.IWriteUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.writeUserEvent(request, options, callback); - } -/** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a 3rd party domain. - * - * This method is used only by the Discovery Engine API JavaScript pixel and - * Google Tag Manager. Users should not call this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent DataStore resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {string} request.userEvent - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - * @param {string} request.uri - * 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. - * @param {number} request.ets - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.api.HttpBody | HttpBody}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/user_event_service.collect_user_event.js - * region_tag:discoveryengine_v1_generated_UserEventService_CollectUserEvent_async - */ - collectUserEvent( - request?: protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|undefined, {}|undefined - ]>; - collectUserEvent( - request: protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request: protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request?: protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1.ICollectUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.collectUserEvent(request, options, callback); - } - -/** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.discoveryengine.v1.ImportUserEventsRequest.InlineSource} request.inlineSource - * Required. The Inline source for the input content for UserEvents. - * @param {google.cloud.discoveryengine.v1.GcsSource} request.gcsSource - * Required. Cloud Storage location for the input content. - * @param {google.cloud.discoveryengine.v1.BigQuerySource} request.bigquerySource - * Required. BigQuery input source. - * @param {string} request.parent - * Required. Parent DataStore resource name, of the form - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` - * @param {google.cloud.discoveryengine.v1.ImportErrorConfig} request.errorConfig - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/user_event_service.import_user_events.js - * region_tag:discoveryengine_v1_generated_UserEventService_ImportUserEvents_async - */ - importUserEvents( - request?: protos.google.cloud.discoveryengine.v1.IImportUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importUserEvents( - request: protos.google.cloud.discoveryengine.v1.IImportUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request: protos.google.cloud.discoveryengine.v1.IImportUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request?: protos.google.cloud.discoveryengine.v1.IImportUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.importUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/user_event_service.import_user_events.js - * region_tag:discoveryengine_v1_generated_UserEventService_ImportUserEvents_async - */ - async checkImportUserEventsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importUserEvents, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationDataStorePath(project:string,location:string,dataStore:string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.userEventServiceStub && !this._terminated) { - return this.userEventServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client_config.json deleted file mode 100644 index 4592e12161a..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_client_config.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1.UserEventService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "WriteUserEvent": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "CollectUserEvent": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ImportUserEvents": { - "timeout_millis": 300000, - "retry_codes_name": "unavailable", - "retry_params_name": "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_proto_list.json deleted file mode 100644 index 60d54073cfa..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/src/v1/user_event_service_proto_list.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1/common.proto", - "../../protos/google/cloud/discoveryengine/v1/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1/document.proto", - "../../protos/google/cloud/discoveryengine/v1/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1/schema.proto", - "../../protos/google/cloud/discoveryengine/v1/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index fa16af05106..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2023 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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const discoveryengine = require('@google-cloud/discoveryengine'); - -function main() { - const completionServiceClient = new discoveryengine.CompletionServiceClient(); - const documentServiceClient = new discoveryengine.DocumentServiceClient(); - const schemaServiceClient = new discoveryengine.SchemaServiceClient(); - const searchServiceClient = new discoveryengine.SearchServiceClient(); - const userEventServiceClient = new discoveryengine.UserEventServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 01e942f0968..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2023 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. ** - -import {CompletionServiceClient, DocumentServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient} from '@google-cloud/discoveryengine'; - -// check that the client class type name can be used -function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { - client.close(); -} -function doStuffWithDocumentServiceClient(client: DocumentServiceClient) { - client.close(); -} -function doStuffWithSchemaServiceClient(client: SchemaServiceClient) { - client.close(); -} -function doStuffWithSearchServiceClient(client: SearchServiceClient) { - client.close(); -} -function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const completionServiceClient = new CompletionServiceClient(); - doStuffWithCompletionServiceClient(completionServiceClient); - // check that the client instance can be created - const documentServiceClient = new DocumentServiceClient(); - doStuffWithDocumentServiceClient(documentServiceClient); - // check that the client instance can be created - const schemaServiceClient = new SchemaServiceClient(); - doStuffWithSchemaServiceClient(schemaServiceClient); - // check that the client instance can be created - const searchServiceClient = new SearchServiceClient(); - doStuffWithSearchServiceClient(searchServiceClient); - // check that the client instance can be created - const userEventServiceClient = new UserEventServiceClient(); - doStuffWithUserEventServiceClient(userEventServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/install.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 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. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_completion_service_v1.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_completion_service_v1.ts deleted file mode 100644 index 05a807b7923..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_completion_service_v1.ts +++ /dev/null @@ -1,609 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as completionserviceModule from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1.CompletionServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = completionserviceModule.v1.CompletionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = completionserviceModule.v1.CompletionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = completionserviceModule.v1.CompletionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new completionserviceModule.v1.CompletionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new completionserviceModule.v1.CompletionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - await client.initialize(); - assert(client.completionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.completionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('completeQuery', () => { - it('invokes completeQuery without error', async () => { - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CompleteQueryRequest', ['dataStore']); - request.dataStore = defaultValue1; - const expectedHeaderRequestParams = `data_store=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CompleteQueryResponse() - ); - client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); - const [response] = await client.completeQuery(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes completeQuery without error using callback', async () => { - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CompleteQueryRequest', ['dataStore']); - request.dataStore = defaultValue1; - const expectedHeaderRequestParams = `data_store=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CompleteQueryResponse() - ); - client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.completeQuery( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.ICompleteQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes completeQuery with error', async () => { - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CompleteQueryRequest', ['dataStore']); - request.dataStore = defaultValue1; - const expectedHeaderRequestParams = `data_store=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes completeQuery with closed client', async () => { - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CompleteQueryRequest', ['dataStore']); - request.dataStore = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.completeQuery(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStore', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - }; - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStorePath', () => { - const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStore', () => { - const fakePath = "/rendered/path/projectLocationDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - }; - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStorePath', () => { - const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreName', () => { - const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreName', () => { - const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new completionserviceModule.v1.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_document_service_v1.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_document_service_v1.ts deleted file mode 100644 index c1dfc6418c4..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_document_service_v1.ts +++ /dev/null @@ -1,1824 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as documentserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.DocumentServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = documentserviceModule.v1.DocumentServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = documentserviceModule.v1.DocumentServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = documentserviceModule.v1.DocumentServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new documentserviceModule.v1.DocumentServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentServiceStub, undefined); - await client.initialize(); - assert(client.documentServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.documentServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('getDocument', () => { - it('invokes getDocument without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.Document() - ); - client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); - const [response] = await client.getDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocument without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.Document() - ); - client.innerApiCalls.getDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDocument( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocument with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocument with closed client', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDocument(request), expectedError); - }); - }); - - describe('createDocument', () => { - it('invokes createDocument without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.Document() - ); - client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); - const [response] = await client.createDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocument without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.Document() - ); - client.innerApiCalls.createDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDocument( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocument with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocument with closed client', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createDocument(request), expectedError); - }); - }); - - describe('updateDocument', () => { - it('invokes updateDocument without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.UpdateDocumentRequest() - ); - request.document ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.Document() - ); - client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); - const [response] = await client.updateDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocument without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.UpdateDocumentRequest() - ); - request.document ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.Document() - ); - client.innerApiCalls.updateDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDocument( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocument with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.UpdateDocumentRequest() - ); - request.document ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocument with closed client', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.UpdateDocumentRequest() - ); - request.document ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateDocument(request), expectedError); - }); - }); - - describe('deleteDocument', () => { - it('invokes deleteDocument without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocument without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDocument( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocument with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocument with closed client', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteDocument(request), expectedError); - }); - }); - - describe('importDocuments', () => { - it('invokes importDocuments without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ImportDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importDocuments = stubLongRunningCall(expectedResponse); - const [operation] = await client.importDocuments(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importDocuments without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ImportDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importDocuments = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importDocuments( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importDocuments with call error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ImportDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importDocuments with LRO error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ImportDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportDocumentsProgress without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportDocumentsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportDocumentsProgress with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportDocumentsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('purgeDocuments', () => { - it('invokes purgeDocuments without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.PurgeDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.PurgeDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeDocuments = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeDocuments(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeDocuments without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.PurgeDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.PurgeDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeDocuments = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeDocuments( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeDocuments with call error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.PurgeDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.PurgeDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeDocuments with LRO error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.PurgeDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.PurgeDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkPurgeDocumentsProgress without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeDocumentsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeDocumentsProgress with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeDocumentsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listDocuments', () => { - it('invokes listDocuments without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - ]; - client.innerApiCalls.listDocuments = stubSimpleCall(expectedResponse); - const [response] = await client.listDocuments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDocuments without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - ]; - client.innerApiCalls.listDocuments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDocuments( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.IDocument[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDocuments with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDocumentsStream without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - ]; - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDocumentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1.Document[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1.Document) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); - assert( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listDocumentsStream with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDocumentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1.Document[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1.Document) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); - assert( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDocuments without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Document()), - ]; - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.discoveryengine.v1.IDocument[] = []; - const iterable = client.listDocumentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDocuments with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDocumentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.discoveryengine.v1.IDocument[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStoreBranch', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchPath', () => { - const result = client.projectLocationCollectionDataStoreBranchPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranch', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchPath', () => { - const result = client.projectLocationDataStoreBranchPath("projectValue", "locationValue", "dataStoreValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_schema_service_v1.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_schema_service_v1.ts deleted file mode 100644 index 2c7d818420c..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_schema_service_v1.ts +++ /dev/null @@ -1,1638 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as schemaserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.SchemaServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = schemaserviceModule.v1.SchemaServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = schemaserviceModule.v1.SchemaServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = schemaserviceModule.v1.SchemaServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new schemaserviceModule.v1.SchemaServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.schemaServiceStub, undefined); - await client.initialize(); - assert(client.schemaServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.schemaServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.schemaServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('getSchema', () => { - it('invokes getSchema without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.GetSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.Schema() - ); - client.innerApiCalls.getSchema = stubSimpleCall(expectedResponse); - const [response] = await client.getSchema(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchema without error using callback', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.GetSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.Schema() - ); - client.innerApiCalls.getSchema = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSchema( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.ISchema|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchema with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.GetSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSchema = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchema with closed client', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.GetSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.GetSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getSchema(request), expectedError); - }); - }); - - describe('createSchema', () => { - it('invokes createSchema without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CreateSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSchema = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSchema(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSchema without error using callback', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CreateSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSchema = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSchema( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSchema with call error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CreateSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSchema = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSchema with LRO error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CreateSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CreateSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSchema = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSchema(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateSchemaProgress without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateSchemaProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateSchemaProgress with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateSchemaProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateSchema', () => { - it('invokes updateSchema without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.UpdateSchemaRequest() - ); - request.schema ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateSchemaRequest', ['schema', 'name']); - request.schema.name = defaultValue1; - const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSchema = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateSchema(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSchema without error using callback', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.UpdateSchemaRequest() - ); - request.schema ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateSchemaRequest', ['schema', 'name']); - request.schema.name = defaultValue1; - const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSchema = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSchema( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSchema with call error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.UpdateSchemaRequest() - ); - request.schema ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateSchemaRequest', ['schema', 'name']); - request.schema.name = defaultValue1; - const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSchema = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSchema with LRO error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.UpdateSchemaRequest() - ); - request.schema ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.UpdateSchemaRequest', ['schema', 'name']); - request.schema.name = defaultValue1; - const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSchema = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateSchema(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateSchemaProgress without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateSchemaProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateSchemaProgress with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateSchemaProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteSchema', () => { - it('invokes deleteSchema without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.DeleteSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSchema = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteSchema(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSchema without error using callback', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.DeleteSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSchema = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSchema( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSchema with call error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.DeleteSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSchema = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSchema with LRO error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.DeleteSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.DeleteSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSchema = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteSchema(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteSchemaProgress without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteSchemaProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteSchemaProgress with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteSchemaProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listSchemas', () => { - it('invokes listSchemas without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - ]; - client.innerApiCalls.listSchemas = stubSimpleCall(expectedResponse); - const [response] = await client.listSchemas(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSchemas without error using callback', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - ]; - client.innerApiCalls.listSchemas = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSchemas( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.ISchema[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSchemas with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSchemas = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSchemas(request), expectedError); - const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSchemasStream without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - ]; - client.descriptors.page.listSchemas.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSchemasStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1.Schema[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1.Schema) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSchemas.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSchemas, request)); - assert( - (client.descriptors.page.listSchemas.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listSchemasStream with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSchemas.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSchemasStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1.Schema[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1.Schema) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSchemas.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSchemas, request)); - assert( - (client.descriptors.page.listSchemas.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSchemas without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.Schema()), - ]; - client.descriptors.page.listSchemas.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.discoveryengine.v1.ISchema[] = []; - const iterable = client.listSchemasAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSchemas.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSchemas.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSchemas with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSchemas.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSchemasAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.discoveryengine.v1.ISchema[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSchemas.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSchemas.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStore', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - }; - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStorePath', () => { - const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStore', () => { - const fakePath = "/rendered/path/projectLocationDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - }; - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStorePath', () => { - const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreName', () => { - const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreName', () => { - const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new schemaserviceModule.v1.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_search_service_v1.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_search_service_v1.ts deleted file mode 100644 index e7dd3e7b80a..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_search_service_v1.ts +++ /dev/null @@ -1,925 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as searchserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.SearchServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = searchserviceModule.v1.SearchServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = searchserviceModule.v1.SearchServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = searchserviceModule.v1.SearchServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new searchserviceModule.v1.SearchServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new searchserviceModule.v1.SearchServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - await client.initialize(); - assert(client.searchServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.searchServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('search', () => { - it('invokes search without error', async () => { - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCall(expectedResponse); - const [response] = await client.search(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes search without error using callback', async () => { - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.search( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes search with error', async () => { - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchStream without error', async () => { - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes searchStream with error', async () => { - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with search without error', async () => { - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult[] = []; - const iterable = client.searchAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with search with error', async () => { - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.discoveryengine.v1.SearchResponse.ISearchResult[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStoreBranch', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - }; - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchPath', () => { - const result = client.projectLocationCollectionDataStoreBranchPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreServingConfig', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreServingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - serving_config: "servingConfigValue", - }; - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreServingConfigPath', () => { - const result = client.projectLocationCollectionDataStoreServingConfigPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranch', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - }; - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchPath', () => { - const result = client.projectLocationDataStoreBranchPath("projectValue", "locationValue", "dataStoreValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreServingConfig', () => { - const fakePath = "/rendered/path/projectLocationDataStoreServingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - serving_config: "servingConfigValue", - }; - const client = new searchserviceModule.v1.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreServingConfigPath', () => { - const result = client.projectLocationDataStoreServingConfigPath("projectValue", "locationValue", "dataStoreValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchProjectFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchLocationFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchServingConfigFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_user_event_service_v1.ts b/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_user_event_service_v1.ts deleted file mode 100644 index a192a7eea14..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/test/gapic_user_event_service_v1.ts +++ /dev/null @@ -1,1162 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as usereventserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.UserEventServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = usereventserviceModule.v1.UserEventServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = usereventserviceModule.v1.UserEventServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = usereventserviceModule.v1.UserEventServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new usereventserviceModule.v1.UserEventServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - await client.initialize(); - assert(client.userEventServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.userEventServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('writeUserEvent', () => { - it('invokes writeUserEvent without error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.WriteUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.UserEvent() - ); - client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.writeUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes writeUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.WriteUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.UserEvent() - ); - client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.writeUserEvent( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1.IUserEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes writeUserEvent with error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.WriteUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes writeUserEvent with closed client', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.WriteUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.writeUserEvent(request), expectedError); - }); - }); - - describe('collectUserEvent', () => { - it('invokes collectUserEvent without error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CollectUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.api.HttpBody() - ); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes collectUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CollectUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.api.HttpBody() - ); - client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.collectUserEvent( - request, - (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes collectUserEvent with error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CollectUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes collectUserEvent with closed client', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.CollectUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.collectUserEvent(request), expectedError); - }); - }); - - describe('importUserEvents', () => { - it('invokes importUserEvents without error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ImportUserEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.importUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ImportUserEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importUserEvents( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importUserEvents with call error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ImportUserEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1.ImportUserEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStore', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - }; - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStorePath', () => { - const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStore', () => { - const fakePath = "/rendered/path/projectLocationDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - }; - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStorePath', () => { - const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreName', () => { - const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreName', () => { - const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new usereventserviceModule.v1.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/tsconfig.json b/owl-bot-staging/google-cloud-discoveryengine/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1/webpack.config.js b/owl-bot-staging/google-cloud-discoveryengine/v1/webpack.config.js deleted file mode 100644 index eb56fa1d866..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 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. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'CompletionService', - filename: './completion-service.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintignore b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintrc.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.gitignore b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.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__ diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.jsdoc.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.jsdoc.js deleted file mode 100644 index 69c2c79afc4..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 2023 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/discoveryengine', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.mocharc.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 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. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -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 diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.prettierrc.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 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. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/README.md b/owl-bot-staging/google-cloud-discoveryengine/v1beta/README.md deleted file mode 100644 index 3f2b1b5b595..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/README.md +++ /dev/null @@ -1 +0,0 @@ -Discoveryengine: Nodejs Client diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/linkinator.config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/package.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/package.json deleted file mode 100644 index 96ea5f6882d..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@google-cloud/discoveryengine", - "version": "0.1.0", - "description": "Discoveryengine client for Node.js", - "repository": "googleapis/nodejs-discoveryengine", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google discoveryengine", - "discoveryengine", - "completion service", - "document service", - "recommendation service", - "schema service", - "search service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/common.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/common.proto deleted file mode 100644 index 36a799a9b06..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/common.proto +++ /dev/null @@ -1,129 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; -option (google.api.resource_definition) = { - type: "discoveryengine.googleapis.com/Branch" - pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}" - pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}" -}; -option (google.api.resource_definition) = { - type: "discoveryengine.googleapis.com/DataStore" - pattern: "projects/{project}/locations/{location}/dataStores/{data_store}" - pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}" -}; -option (google.api.resource_definition) = { - type: "discoveryengine.googleapis.com/ServingConfig" - pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}" - pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}" -}; - -// A floating point interval. -message Interval { - // The lower bound of the interval. If neither of the min fields are - // set, then the lower bound is negative infinity. - // - // This field must be not larger than max. - // Otherwise, an `INVALID_ARGUMENT` error is returned. - oneof min { - // Inclusive lower bound. - double minimum = 1; - - // Exclusive lower bound. - double exclusive_minimum = 2; - } - - // The upper bound of the interval. If neither of the max fields are - // set, then the upper bound is positive infinity. - // - // This field must be not smaller than min. - // Otherwise, an `INVALID_ARGUMENT` error is returned. - oneof max { - // Inclusive upper bound. - double maximum = 3; - - // Exclusive upper bound. - double exclusive_maximum = 4; - } -} - -// A custom attribute that is not explicitly modeled in a resource, e.g. -// [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent]. -message CustomAttribute { - // The textual values of this custom attribute. For example, `["yellow", - // "green"]` when the key is "color". - // - // Empty string is not allowed. Otherwise, an `INVALID_ARGUMENT` error is - // returned. - // - // Exactly one of - // [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] - // or - // [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] - // should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. - repeated string text = 1; - - // The numerical values of this custom attribute. For example, `[2.3, 15.4]` - // when the key is "lengths_cm". - // - // Exactly one of - // [CustomAttribute.text][google.cloud.discoveryengine.v1beta.CustomAttribute.text] - // or - // [CustomAttribute.numbers][google.cloud.discoveryengine.v1beta.CustomAttribute.numbers] - // should be set. Otherwise, an `INVALID_ARGUMENT` error is returned. - repeated double numbers = 2; -} - -// Information of an end user. -message UserInfo { - // Highly recommended for logged-in users. Unique identifier for logged-in - // user, such as a user name. Don't set for anonymous users. - // - // Always use a hashed value for this ID. - // - // Don't set the field to the same fixed ID for different users. This mixes - // the event history of those users together, which results in degraded - // model quality. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - string user_id = 1; - - // User agent as included in the HTTP header. Required for getting - // [SearchResponse.sponsored_results][]. - // - // The field must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - // - // This should not be set when using the client side event reporting with - // GTM or JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent] - // or if - // [UserEvent.direct_user_request][google.cloud.discoveryengine.v1beta.UserEvent.direct_user_request] - // is set. - string user_agent = 2; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/completion_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/completion_service.proto deleted file mode 100644 index cd003bd1fa2..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/completion_service.proto +++ /dev/null @@ -1,118 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "CompletionServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// Service for Auto-Completion. -service CompletionService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Completes the specified user input with keyword suggestions. - rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { - option (google.api.http) = { - get: "/v1beta/{data_store=projects/*/locations/*/dataStores/*}:completeQuery" - additional_bindings { - get: "/v1beta/{data_store=projects/*/locations/*/collections/*/dataStores/*}:completeQuery" - } - }; - } -} - -// Request message for -// [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery] -// method. -message CompleteQueryRequest { - // Required. The parent data store resource name for which the completion is - // performed, such as - // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store`. - string data_store = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // Required. The typeahead input used to fetch suggestions. Maximum length is - // 128 characters. - string query = 2 [(google.api.field_behavior) = REQUIRED]; - - // Selects data model of query suggestions for serving. Currently supported - // values: - // - // * `document` - Using suggestions generated from user-imported documents. - // * `search-history` - Using suggestions generated from the past history of - // [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] - // API calls. Do not use it when there is no traffic for Search API. - // * `user-event` - Using suggestions generated from user-imported search - // events. - // * `document-completable` - Using suggestions taken directly from - // user-imported document fields marked as completable. - // - // Default values: - // - // * `document` is the default model for regular dataStores. - // * `search-history` is the default model for - // [IndustryVertical.SITE_SEARCH][google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH] - // dataStores. - string query_model = 3; - - // 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. - // - // This field should NOT have a fixed value such as `unknown_visitor`. - // - // This should be the same identifier as - // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] - // and - // [SearchRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.SearchRequest.user_pseudo_id]. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - string user_pseudo_id = 4; -} - -// Response message for -// [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery] -// method. -message CompleteQueryResponse { - // Suggestions as search queries. - message QuerySuggestion { - // The suggestion for the query. - string suggestion = 1; - } - - // Results of the matched query suggestions. The result list is ordered and - // the first result is a top suggestion. - repeated QuerySuggestion query_suggestions = 1; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document.proto deleted file mode 100644 index 677228d9011..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document.proto +++ /dev/null @@ -1,123 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "DocumentProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// Document captures all raw metadata information of items to be recommended or -// searched. -message Document { - option (google.api.resource) = { - type: "discoveryengine.googleapis.com/Document" - pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}" - pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}" - }; - - // Unstructured data linked to this document. - message Content { - oneof content { - // The content represented as a stream of bytes. The maximum length is - // 1,000,000 bytes (1 MB / ~0.95 MiB). - // - // Note: As with all `bytes` fields, this field is represented as pure - // binary in Protocol Buffers and base64-encoded string in JSON. For - // example, `abc123!?$*&()'-=@~` should be represented as - // `YWJjMTIzIT8kKiYoKSctPUB+` in JSON. See - // https://developers.google.com/protocol-buffers/docs/proto3#json. - bytes raw_bytes = 2; - - // The URI of the content. Only Cloud Storage URIs (e.g. - // `gs://bucket-name/path/to/file`) are supported. The maximum file size - // is 100 MB. - string uri = 3; - } - - // The MIME type of the content. Supported types: - // - // * `application/pdf` (PDF, only native PDFs are supported for now) - // * `text/html` (HTML) - // * `application/vnd.openxmlformats-officedocument.wordprocessingml.document` (DOCX) - // * `application/vnd.openxmlformats-officedocument.presentationml.presentation` (PPTX) - // * `text/plain` (TXT) - // - // See https://www.iana.org/assignments/media-types/media-types.xhtml. - string mime_type = 1; - } - - // Data representation. One of - // [struct_data][google.cloud.discoveryengine.v1beta.Document.struct_data] or - // [json_data][google.cloud.discoveryengine.v1beta.Document.json_data] should - // be provided otherwise an `INVALID_ARGUMENT` error is thrown. - oneof data { - // The structured JSON data for the document. It should conform to the - // registered - // [Schema.schema][google.cloud.discoveryengine.v1beta.Schema.schema] or an - // `INVALID_ARGUMENT` error is thrown. - google.protobuf.Struct struct_data = 4; - - // The JSON string representation of the document. It should conform to the - // registered - // [Schema.schema][google.cloud.discoveryengine.v1beta.Schema.schema] or an - // `INVALID_ARGUMENT` error is thrown. - string json_data = 5; - } - - // Immutable. The full resource name of the document. - // Format: - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document_id}`. - // - // This field must be a UTF-8 encoded string with a length limit of 1024 - // characters. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The identifier of the document. - // - // Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) - // standard with a length limit of 63 characters. - string id = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // The identifier of the schema located in the same data store. - string schema_id = 3; - - // The unstructured data linked to this document. Content must be set if this - // document is under a - // `CONTENT_REQUIRED` data store. - Content content = 10; - - // The identifier of the parent document. Currently supports at most two level - // document hierarchy. - // - // Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) - // standard with a length limit of 63 characters. - string parent_document_id = 7; - - // Output only. This field is OUTPUT_ONLY. - // It contains derived data that are not in the original input document. - google.protobuf.Struct derived_struct_data = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document_service.proto deleted file mode 100644 index e76d7ce56ca..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/document_service.proto +++ /dev/null @@ -1,316 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1beta/document.proto"; -import "google/cloud/discoveryengine/v1beta/import_config.proto"; -import "google/cloud/discoveryengine/v1beta/purge_config.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "DocumentServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// Service for ingesting -// [Document][google.cloud.discoveryengine.v1beta.Document] information of the -// customer's website. -service DocumentService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Gets a [Document][google.cloud.discoveryengine.v1beta.Document]. - rpc GetDocument(GetDocumentRequest) returns (Document) { - option (google.api.http) = { - get: "/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" - additional_bindings { - get: "/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s. - rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) { - option (google.api.http) = { - get: "/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents" - additional_bindings { - get: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a [Document][google.cloud.discoveryengine.v1beta.Document]. - rpc CreateDocument(CreateDocumentRequest) returns (Document) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents" - body: "document" - additional_bindings { - post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents" - body: "document" - } - }; - option (google.api.method_signature) = "parent,document,document_id"; - } - - // Updates a [Document][google.cloud.discoveryengine.v1beta.Document]. - rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { - option (google.api.http) = { - patch: "/v1beta/{document.name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" - body: "document" - additional_bindings { - patch: "/v1beta/{document.name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" - body: "document" - } - }; - } - - // Deletes a [Document][google.cloud.discoveryengine.v1beta.Document]. - rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/documents/*}" - additional_bindings { - delete: "/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/documents/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Bulk import of multiple - // [Document][google.cloud.discoveryengine.v1beta.Document]s. Request - // processing may be synchronous. Non-existing items will be created. - // - // Note: It is possible for a subset of the - // [Document][google.cloud.discoveryengine.v1beta.Document]s to be - // successfully updated. - rpc ImportDocuments(ImportDocumentsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:import" - body: "*" - additional_bindings { - post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:import" - body: "*" - } - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.discoveryengine.v1beta.ImportDocumentsResponse" - metadata_type: "google.cloud.discoveryengine.v1beta.ImportDocumentsMetadata" - }; - } - - // Permanently deletes all selected - // [Document][google.cloud.discoveryengine.v1beta.Document]s in a branch. - // - // This process is asynchronous. Depending on the number of - // [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, - // this operation can take hours to complete. Before the delete operation - // completes, some [Document][google.cloud.discoveryengine.v1beta.Document]s - // might still be returned by - // [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument] - // or - // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments]. - // - // To get a list of the - // [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, - // set - // [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force] - // to false. - rpc PurgeDocuments(PurgeDocumentsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*/locations/*/dataStores/*/branches/*}/documents:purge" - body: "*" - additional_bindings { - post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*/branches/*}/documents:purge" - body: "*" - } - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.discoveryengine.v1beta.PurgeDocumentsResponse" - metadata_type: "google.cloud.discoveryengine.v1beta.PurgeDocumentsMetadata" - }; - } -} - -// Request message for -// [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument] -// method. -message GetDocumentRequest { - // Required. Full resource name of - // [Document][google.cloud.discoveryengine.v1beta.Document], such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - // - // If the caller does not have permission to access the - // [Document][google.cloud.discoveryengine.v1beta.Document], regardless of - // whether or not it exists, a `PERMISSION_DENIED` error is returned. - // - // If the requested [Document][google.cloud.discoveryengine.v1beta.Document] - // does not exist, a `NOT_FOUND` error is returned. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Document" - } - ]; -} - -// Request message for -// [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] -// method. -message ListDocumentsRequest { - // Required. The parent branch resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - // Use `default_branch` as the branch ID, to list documents under the default - // branch. - // - // If the caller does not have permission to list [Documents][]s under this - // branch, regardless of whether or not this branch exists, a - // `PERMISSION_DENIED` error is returned. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Branch" - } - ]; - - // Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]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. - int32 page_size = 2; - - // A page token - // [ListDocumentsResponse.next_page_token][google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token], - // received from a previous - // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] - // must match the call that provided the page token. Otherwise, an - // `INVALID_ARGUMENT` error is returned. - string page_token = 3; -} - -// Response message for -// [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments] -// method. -message ListDocumentsResponse { - // The [Document][google.cloud.discoveryengine.v1beta.Document]s. - repeated Document documents = 1; - - // A token that can be sent as - // [ListDocumentsRequest.page_token][google.cloud.discoveryengine.v1beta.ListDocumentsRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request message for -// [DocumentService.CreateDocument][google.cloud.discoveryengine.v1beta.DocumentService.CreateDocument] -// method. -message CreateDocumentRequest { - // Required. The parent resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Branch" - } - ]; - - // Required. The [Document][google.cloud.discoveryengine.v1beta.Document] to - // create. - Document document = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the - // [Document][google.cloud.discoveryengine.v1beta.Document], which will become - // the final component of the - // [Document.name][google.cloud.discoveryengine.v1beta.Document.name]. - // - // If the caller does not have permission to create the - // [Document][google.cloud.discoveryengine.v1beta.Document], regardless of - // whether or not it exists, a `PERMISSION_DENIED` error is returned. - // - // This field must be unique among all - // [Document][google.cloud.discoveryengine.v1beta.Document]s with the same - // [parent][google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent]. - // Otherwise, an `ALREADY_EXISTS` error is returned. - // - // This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) - // standard with a length limit of 63 characters. Otherwise, an - // `INVALID_ARGUMENT` error is returned. - string document_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for -// [DocumentService.UpdateDocument][google.cloud.discoveryengine.v1beta.DocumentService.UpdateDocument] -// method. -message UpdateDocumentRequest { - // Required. The document to update/create. - // - // If the caller does not have permission to update the - // [Document][google.cloud.discoveryengine.v1beta.Document], regardless of - // whether or not it exists, a `PERMISSION_DENIED` error is returned. - // - // If the [Document][google.cloud.discoveryengine.v1beta.Document] to update - // does not exist and - // [allow_missing][google.cloud.discoveryengine.v1beta.UpdateDocumentRequest.allow_missing] - // is not set, a `NOT_FOUND` error is returned. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // If set to true, and the - // [Document][google.cloud.discoveryengine.v1beta.Document] is not found, a - // new [Document][google.cloud.discoveryengine.v1beta.Document] will be - // created. - bool allow_missing = 2; -} - -// Request message for -// [DocumentService.DeleteDocument][google.cloud.discoveryengine.v1beta.DocumentService.DeleteDocument] -// method. -message DeleteDocumentRequest { - // Required. Full resource name of - // [Document][google.cloud.discoveryengine.v1beta.Document], such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - // - // If the caller does not have permission to delete the - // [Document][google.cloud.discoveryengine.v1beta.Document], regardless of - // whether or not it exists, a `PERMISSION_DENIED` error is returned. - // - // If the [Document][google.cloud.discoveryengine.v1beta.Document] to delete - // does not exist, a `NOT_FOUND` error is returned. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Document" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/import_config.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/import_config.proto deleted file mode 100644 index 9c68d47a0fe..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/import_config.proto +++ /dev/null @@ -1,342 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1beta/document.proto"; -import "google/cloud/discoveryengine/v1beta/user_event.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/date.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "ImportConfigProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// Cloud Storage location for input content. -message GcsSource { - // Required. Cloud Storage URIs to input files. URI can be up to - // 2000 characters long. URIs can match the full object path (for example, - // `gs://bucket/directory/object.json`) or a pattern matching one or more - // files, such as `gs://bucket/directory/*.json`. - // - // A request can contain at most 100 files (or 100,000 files if `data_schema` - // is `content`). Each file can be up to 2 GB (or 100 MB if `data_schema` is - // `content`). - repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; - - // The schema to use when parsing the data from the source. - // - // Supported values for document imports: - // - // * `document` (default): One JSON - // [Document][google.cloud.discoveryengine.v1beta.Document] per line. Each - // document must - // have a valid - // [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. - // * `content`: Unstructured data (e.g. PDF, HTML). Each file matched by - // `input_uris` will become a document, with the ID set to the first 128 - // bits of SHA256(URI) encoded as a hex string. - // * `custom`: One custom data JSON per row in arbitrary format that conforms - // the defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the - // data store. This can only be used by the GENERIC Data Store vertical. - // * `csv`: A CSV file with header conforming the defined - // [Schema][google.cloud.discoveryengine.v1beta.Schema] of the - // data store. Each entry after the header will be imported as a Document. - // This can only be used by the GENERIC Data Store vertical. - // - // Supported values for user even imports: - // - // * `user_event` (default): One JSON - // [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per line. - string data_schema = 2; -} - -// BigQuery source import data from. -message BigQuerySource { - // BigQuery table partition info. Leave this empty if the BigQuery table - // is not partitioned. - oneof partition { - // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. - google.type.Date partition_date = 5; - } - - // The project ID (can be project # or ID) that the BigQuery source is in with - // a length limit of 128 characters. If not specified, inherits the project - // ID from the parent request. - string project_id = 1; - - // Required. The BigQuery data set to copy the data from with a length limit - // of 1,024 characters. - string dataset_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The BigQuery table to copy the data from with a length limit of - // 1,024 characters. - string table_id = 3 [(google.api.field_behavior) = REQUIRED]; - - // Intermediate Cloud Storage directory used for the import with a length - // limit of 2,000 characters. Can be specified if one wants to have the - // BigQuery export to a specific Cloud Storage directory. - string gcs_staging_dir = 4; - - // The schema to use when parsing the data from the source. - // - // Supported values for user event imports: - // - // * `user_event` (default): One - // [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] per row. - // - // Supported values for document imports: - // - // * `document` (default): One - // [Document][google.cloud.discoveryengine.v1beta.Document] format per - // row. Each document must have a valid - // [Document.id][google.cloud.discoveryengine.v1beta.Document.id] and one of - // [Document.json_data][google.cloud.discoveryengine.v1beta.Document.json_data] - // or - // [Document.struct_data][google.cloud.discoveryengine.v1beta.Document.struct_data]. - // * `custom`: One custom data per row in arbitrary format that conforms the - // defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the data - // store. This can only be used by the GENERIC Data Store vertical. - string data_schema = 6; -} - -// Configuration of destination for Import related errors. -message ImportErrorConfig { - // Required. Errors destination. - oneof destination { - // Cloud Storage prefix for import errors. This must be an empty, - // existing Cloud Storage directory. Import errors will be written to - // sharded files in this directory, one per line, as a JSON-encoded - // `google.rpc.Status` message. - string gcs_prefix = 1; - } -} - -// Request message for the ImportUserEvents request. -message ImportUserEventsRequest { - // The inline source for the input config for ImportUserEvents method. - message InlineSource { - // Required. A list of user events to import. Recommended max of 10k items. - repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // Required - The desired input source of the user event data. - oneof source { - // The Inline source for the input content for UserEvents. - InlineSource inline_source = 2; - - // Cloud Storage location for the input content. - GcsSource gcs_source = 3; - - // BigQuery input source. - BigQuerySource bigquery_source = 4; - } - - // Required. Parent DataStore resource name, of the form - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // The desired location of errors incurred during the Import. Cannot be set - // for inline user event imports. - ImportErrorConfig error_config = 5; -} - -// Response of the ImportUserEventsRequest. If the long running -// operation was successful, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportUserEventsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors if this field was set in - // the request. - ImportErrorConfig error_config = 2; - - // Count of user events imported with complete existing Documents. - int64 joined_events_count = 3; - - // Count of user events imported, but with Document information not found - // in the existing Branch. - int64 unjoined_events_count = 4; -} - -// Metadata related to the progress of the Import operation. This will be -// returned by the google.longrunning.Operation.metadata field. -message ImportUserEventsMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were processed successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; -} - -// Metadata related to the progress of the ImportDocuments operation. This will -// be returned by the google.longrunning.Operation.metadata field. -message ImportDocumentsMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were processed successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; -} - -// Request message for Import methods. -message ImportDocumentsRequest { - // The inline source for the input config for ImportDocuments method. - message InlineSource { - // Required. A list of documents to update/create. Each document must have a - // valid [Document.id][google.cloud.discoveryengine.v1beta.Document.id]. - // Recommended max of 100 items. - repeated Document documents = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // Indicates how imported documents are reconciled with the existing documents - // created or imported before. - enum ReconciliationMode { - // Defaults to INCREMENTAL. - RECONCILIATION_MODE_UNSPECIFIED = 0; - - // Inserts new documents or updates existing documents. - INCREMENTAL = 1; - - // Calculates diff and replaces the entire document dataset. Existing - // documents may be deleted if they are not present in the source location. - FULL = 2; - } - - // Required. The source of the input. - oneof source { - // The Inline source for the input content for documents. - InlineSource inline_source = 2; - - // Cloud Storage location for the input content. - GcsSource gcs_source = 3; - - // BigQuery input source. - BigQuerySource bigquery_source = 4; - } - - // Required. The parent branch resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - // Requires create/update permission. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Branch" - } - ]; - - // The desired location of errors incurred during the Import. - ImportErrorConfig error_config = 5; - - // The mode of reconciliation between existing documents and the documents to - // be imported. Defaults to - // [ReconciliationMode.INCREMENTAL][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL]. - ReconciliationMode reconciliation_mode = 6; - - // Whether to automatically generate IDs for the documents if absent. - // - // If set to `true`, - // [Document.id][google.cloud.discoveryengine.v1beta.Document.id]s are - // automatically generated based on the hash of the payload, where IDs may not - // be consistent during multiple imports. In which case - // [ReconciliationMode.FULL][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.FULL] - // is highly recommended to avoid duplicate contents. If unset or set to - // `false`, [Document.id][google.cloud.discoveryengine.v1beta.Document.id]s - // have to be specified using - // [id_field][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.id_field], - // otherwises, documents without IDs will fail to be imported. - // - // Only set this field when using - // [GcsSource][google.cloud.discoveryengine.v1beta.GcsSource] or - // [BigQuerySource][google.cloud.discoveryengine.v1beta.BigQuerySource], and - // when - // [GcsSource.data_schema][google.cloud.discoveryengine.v1beta.GcsSource.data_schema] - // or - // [BigQuerySource.data_schema][google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema] - // is `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown. - bool auto_generate_ids = 8; - - // The field in the Cloud Storage and BigQuery sources that indicates the - // unique IDs of the documents. - // - // For [GcsSource][google.cloud.discoveryengine.v1beta.GcsSource] it is the - // key of the JSON field. For instance, `my_id` for JSON `{"my_id": - // "some_uuid"}`. For - // [BigQuerySource][google.cloud.discoveryengine.v1beta.BigQuerySource] it is - // the column name of the BigQuery table where the unique ids are stored. - // - // The values of the JSON field or the BigQuery column will be used as the - // [Document.id][google.cloud.discoveryengine.v1beta.Document.id]s. The JSON - // field or the BigQuery column must be of string type, and the values must be - // set as valid strings conform to - // [RFC-1034](https://tools.ietf.org/html/rfc1034) with 1-63 characters. - // Otherwise, documents without valid IDs will fail to be imported. - // - // Only set this field when using - // [GcsSource][google.cloud.discoveryengine.v1beta.GcsSource] or - // [BigQuerySource][google.cloud.discoveryengine.v1beta.BigQuerySource], and - // when - // [GcsSource.data_schema][google.cloud.discoveryengine.v1beta.GcsSource.data_schema] - // or - // [BigQuerySource.data_schema][google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema] - // is `custom`. And only set this field when - // [auto_generate_ids][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.auto_generate_ids] - // is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. - // - // If it is unset, a default value `_id` is used when importing from the - // allowed data sources. - string id_field = 9; -} - -// Response of the -// [ImportDocumentsRequest][google.cloud.discoveryengine.v1beta.ImportDocumentsRequest]. -// If the long running operation is done, then this message is returned by the -// google.longrunning.Operations.response field if the operation was successful. -message ImportDocumentsResponse { - // A sample of errors encountered while processing the request. - repeated google.rpc.Status error_samples = 1; - - // Echoes the destination for the complete errors in the request if set. - ImportErrorConfig error_config = 2; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/purge_config.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/purge_config.proto deleted file mode 100644 index 559bc4a021c..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/purge_config.proto +++ /dev/null @@ -1,86 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "PurgeConfigProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// Request message for -// [DocumentService.PurgeDocuments][google.cloud.discoveryengine.v1beta.DocumentService.PurgeDocuments] -// method. -message PurgeDocumentsRequest { - // Required. The parent resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Branch" - } - ]; - - // Required. Filter matching documents to purge. Only currently supported - // value is - // `*` (all items). - string filter = 2 [(google.api.field_behavior) = REQUIRED]; - - // Actually performs the purge. If `force` is set to false, return the - // expected purge count without deleting any documents. - bool force = 3; -} - -// Response message for -// [DocumentService.PurgeDocuments][google.cloud.discoveryengine.v1beta.DocumentService.PurgeDocuments] -// method. If the long running operation is successfully done, then this message -// is returned by the google.longrunning.Operations.response field. -message PurgeDocumentsResponse { - // The total count of documents purged as a result of the operation. - int64 purge_count = 1; - - // A sample of document names that will be deleted. Only populated if `force` - // is set to false. A max of 100 names will be returned and the names are - // chosen at random. - repeated string purge_sample = 2 [(google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Document" - }]; -} - -// Metadata related to the progress of the PurgeDocuments operation. -// This will be returned by the google.longrunning.Operation.metadata field. -message PurgeDocumentsMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; - - // Count of entries that were deleted successfully. - int64 success_count = 3; - - // Count of entries that encountered errors while processing. - int64 failure_count = 4; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto deleted file mode 100644 index 85eb652f205..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto +++ /dev/null @@ -1,206 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1beta/document.proto"; -import "google/cloud/discoveryengine/v1beta/user_event.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "RecommendationServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// Service for making recommendations. -service RecommendationService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Makes a recommendation, which requires a contextual user event. - rpc Recommend(RecommendRequest) returns (RecommendResponse) { - option (google.api.http) = { - post: "/v1beta/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:recommend" - body: "*" - additional_bindings { - post: "/v1beta/{serving_config=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:recommend" - body: "*" - } - }; - } -} - -// Request message for Recommend method. -message RecommendRequest { - // Required. Full resource name of the format: - // `projects/*/locations/global/collections/*/dataStores/*/servingConfigs/*` - // - // Before you can request recommendations from your model, you must create at - // least one serving config for it. - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/ServingConfig" - } - ]; - - // Required. Context about the user, what they are looking at and what action - // they took to trigger the Recommend 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.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] - // or - // [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.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.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] - // to a random unique ID and leave - // [UserEvent.user_info.user_id][google.cloud.discoveryengine.v1beta.UserInfo.user_id] - // unset. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // Maximum number of results to return. Set this property - // to the number of recommendation 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. - int32 page_size = 3; - - // Filter for restricting recommendation results with a length limit of 5,000 - // characters. Currently, only filter expressions on the `filter_tags` - // attribute is supported. - // - // - // Examples: - // - // * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))` - // * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))` - // - // If your filter blocks all results, the API will return generic - // (unfiltered) popular Documents. If you only want results strictly matching - // the filters, set `strictFiltering` to True in - // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params] - // to receive empty results instead. - // - // Note that the API will never return - // [Document][google.cloud.discoveryengine.v1beta.Document]s with - // `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices. - string filter = 4; - - // Use validate only mode for this recommendation query. If set to true, a - // fake model will be used that returns arbitrary Document IDs. - // Note that the validate only mode should only be used for testing the API, - // or if the model is not ready. - bool validate_only = 5; - - // Additional domain specific parameters for the recommendations. - // - // Allowed values: - // - // * `returnDocument`: Boolean. If set to true, the associated Document - // object will be returned in - // [RecommendResponse.RecommendationResult.document][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document]. - // * `returnScore`: Boolean. If set to true, the recommendation 'score' - // corresponding to each returned Document will be set in - // [RecommendResponse.RecommendationResult.metadata][google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata]. - // The given 'score' indicates the probability of a Document conversion - // given the user's context and history. - // * `strictFiltering`: Boolean. True by default. If set to false, the service - // will return generic (unfiltered) popular Documents instead of empty if - // your filter blocks all recommendation results. - // * `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 recommendation results - // based on Document category. - map params = 6; - - // The user 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 [Requirements for - // labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - // for more details. - map user_labels = 8; -} - -// Response message for Recommend method. -message RecommendResponse { - // RecommendationResult represents a generic recommendation result with - // associated metadata. - message RecommendationResult { - // Resource ID of the recommended Document. - string id = 1; - - // Set if `returnDocument` is set to true in - // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. - Document document = 2; - - // Additional Document metadata / annotations. - // - // Possible values: - // - // * `score`: Recommendation score in double value. Is set if - // `returnScore` is set to true in - // [RecommendRequest.params][google.cloud.discoveryengine.v1beta.RecommendRequest.params]. - map metadata = 3; - } - - // A list of recommended Documents. The order represents the ranking (from the - // most relevant Document to the least). - repeated RecommendationResult results = 1; - - // A unique attribution token. This should be included in the - // [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting - // from this recommendation, which enables accurate attribution of - // recommendation model performance. - string attribution_token = 2; - - // IDs of documents in the request that were missing from the default Branch - // associated with the requested ServingConfig. - repeated string missing_ids = 3; - - // True if - // [RecommendRequest.validate_only][google.cloud.discoveryengine.v1beta.RecommendRequest.validate_only] - // was set. - bool validate_only = 4; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema.proto deleted file mode 100644 index ffc58799108..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema.proto +++ /dev/null @@ -1,58 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "SchemaProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// Defines the structure and layout of a type of document data. -message Schema { - option (google.api.resource) = { - type: "discoveryengine.googleapis.com/Schema" - pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}" - pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}" - }; - - // Schema representation. One of - // [struct_schema][google.cloud.discoveryengine.v1beta.Schema.struct_schema] - // or [json_schema][google.cloud.discoveryengine.v1beta.Schema.json_schema] - // should be provided otherwise an INVALID_ARGUMENT error is thrown. - oneof schema { - // The structured representation of the schema. - google.protobuf.Struct struct_schema = 2; - - // The JSON representation of the schema. - string json_schema = 3; - } - - // Immutable. The full resource name of the schema, in the format of - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - // - // This field must be a UTF-8 encoded string with a length limit of 1024 - // characters. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema_service.proto deleted file mode 100644 index bad4b913927..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/schema_service.proto +++ /dev/null @@ -1,259 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1beta/schema.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "SchemaServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// Service for managing [Schema][google.cloud.discoveryengine.v1beta.Schema]s. -service SchemaService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Gets a [Schema][google.cloud.discoveryengine.v1beta.Schema]. - rpc GetSchema(GetSchemaRequest) returns (Schema) { - option (google.api.http) = { - get: "/v1beta/{name=projects/*/locations/*/dataStores/*/schemas/*}" - additional_bindings { - get: "/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Gets a list of [Schema][google.cloud.discoveryengine.v1beta.Schema]s. - rpc ListSchemas(ListSchemasRequest) returns (ListSchemasResponse) { - option (google.api.http) = { - get: "/v1beta/{parent=projects/*/locations/*/dataStores/*}/schemas" - additional_bindings { - get: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/schemas" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a [Schema][google.cloud.discoveryengine.v1beta.Schema]. - rpc CreateSchema(CreateSchemaRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*/locations/*/dataStores/*}/schemas" - body: "schema" - additional_bindings { - post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/schemas" - body: "schema" - } - }; - option (google.api.method_signature) = "parent,schema,schema_id"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.discoveryengine.v1beta.Schema" - metadata_type: "google.cloud.discoveryengine.v1beta.CreateSchemaMetadata" - }; - } - - // Updates a [Schema][google.cloud.discoveryengine.v1beta.Schema]. - rpc UpdateSchema(UpdateSchemaRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1beta/{schema.name=projects/*/locations/*/dataStores/*/schemas/*}" - body: "schema" - additional_bindings { - patch: "/v1beta/{schema.name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" - body: "schema" - } - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.discoveryengine.v1beta.Schema" - metadata_type: "google.cloud.discoveryengine.v1beta.UpdateSchemaMetadata" - }; - } - - // Deletes a [Schema][google.cloud.discoveryengine.v1beta.Schema]. - rpc DeleteSchema(DeleteSchemaRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1beta/{name=projects/*/locations/*/dataStores/*/schemas/*}" - additional_bindings { - delete: "/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "google.cloud.discoveryengine.v1beta.DeleteSchemaMetadata" - }; - } -} - -// Request message for -// [SchemaService.GetSchema][google.cloud.discoveryengine.v1beta.SchemaService.GetSchema] -// method. -message GetSchemaRequest { - // Required. The full resource name of the schema, in the format of - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Schema" - } - ]; -} - -// Request message for -// [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] -// method. -message ListSchemasRequest { - // Required. The parent data store resource name, in the format of - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // The maximum number of [Schema][google.cloud.discoveryengine.v1beta.Schema]s - // to return. The service may return fewer than this value. - // - // If unspecified, at most 100 - // [Schema][google.cloud.discoveryengine.v1beta.Schema]s will be returned. - // - // The maximum value is 1000; values above 1000 will be coerced to 1000. - int32 page_size = 2; - - // A page token, received from a previous - // [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] - // must match the call that provided the page token. - string page_token = 3; -} - -// Response message for -// [SchemaService.ListSchemas][google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas] -// method. -message ListSchemasResponse { - // The [Schema][google.cloud.discoveryengine.v1beta.Schema]s. - repeated Schema schemas = 1; - - // A token that can be sent as - // [ListSchemasRequest.page_token][google.cloud.discoveryengine.v1beta.ListSchemasRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 2; -} - -// Request message for -// [SchemaService.CreateSchema][google.cloud.discoveryengine.v1beta.SchemaService.CreateSchema] -// method. -message CreateSchemaRequest { - // Required. The parent data store resource name, in the format of - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to - // create. - Schema schema = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the - // [Schema][google.cloud.discoveryengine.v1beta.Schema], which will become the - // final component of the - // [Schema.name][google.cloud.discoveryengine.v1beta.Schema.name]. - // - // This field should conform to - // [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length - // limit of 63 characters. - string schema_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for -// [SchemaService.UpdateSchema][google.cloud.discoveryengine.v1beta.SchemaService.UpdateSchema] -// method. -message UpdateSchemaRequest { - // Required. The [Schema][google.cloud.discoveryengine.v1beta.Schema] to - // update. - Schema schema = 1 [(google.api.field_behavior) = REQUIRED]; - - // If set to true, and the - // [Schema][google.cloud.discoveryengine.v1beta.Schema] is not found, a new - // [Schema][google.cloud.discoveryengine.v1beta.Schema] will be created. In - // this situation, `update_mask` is ignored. - bool allow_missing = 3; -} - -// Request message for -// [SchemaService.DeleteSchema][google.cloud.discoveryengine.v1beta.SchemaService.DeleteSchema] -// method. -message DeleteSchemaRequest { - // Required. The full resource name of the schema, in the format of - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Schema" - } - ]; -} - -// Metadata for Create Schema LRO. -message CreateSchemaMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; -} - -// Metadata for UpdateSchema LRO. -message UpdateSchemaMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; -} - -// Metadata for DeleteSchema LRO. -message DeleteSchemaMetadata { - // Operation create time. - google.protobuf.Timestamp create_time = 1; - - // Operation last update time. If the operation is done, this is also the - // finish time. - google.protobuf.Timestamp update_time = 2; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/search_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/search_service.proto deleted file mode 100644 index 21c48e0734d..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/search_service.proto +++ /dev/null @@ -1,617 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1beta/common.proto"; -import "google/cloud/discoveryengine/v1beta/document.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "SearchServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// Service for search. -service SearchService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Performs a search. - rpc Search(SearchRequest) returns (SearchResponse) { - option (google.api.http) = { - post: "/v1beta/{serving_config=projects/*/locations/*/dataStores/*/servingConfigs/*}:search" - body: "*" - additional_bindings { - post: "/v1beta/{serving_config=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:search" - body: "*" - } - }; - } -} - -// Request message for -// [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] -// method. -message SearchRequest { - // A facet specification to perform faceted search. - message FacetSpec { - // Specifies how a facet is computed. - message FacetKey { - // Required. Supported textual and numerical facet keys in - // [Document][google.cloud.discoveryengine.v1beta.Document] object, over - // which the facet values are computed. Facet key is case-sensitive. - string key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Set only if values should be bucketized into intervals. Must be set - // for facets with numerical values. Must not be set for facet with text - // values. Maximum number of intervals is 30. - repeated Interval intervals = 2; - - // Only get facet for the given restricted values. Only supported on - // textual fields. For example, suppose "category" has three values - // "Action > 2022", "Action > 2021" and "Sci-Fi > 2022". If set - // "restricted_values" to "Action > 2022", the "category" facet will only - // contain "Action > 2022". Only supported on textual fields. Maximum - // is 10. - repeated string restricted_values = 3; - - // Only get facet values that start with the given string prefix. For - // example, suppose "category" has three values "Action > 2022", - // "Action > 2021" and "Sci-Fi > 2022". If set "prefixes" to "Action", the - // "category" facet will only contain "Action > 2022" and "Action > 2021". - // Only supported on textual fields. Maximum is 10. - repeated string prefixes = 4; - - // Only get facet values that contains the given strings. For example, - // suppose "category" has three values "Action > 2022", - // "Action > 2021" and "Sci-Fi > 2022". If set "contains" to "2022", the - // "category" facet will only contain "Action > 2022" and "Sci-Fi > 2022". - // Only supported on textual fields. Maximum is 10. - repeated string contains = 5; - - // True to make facet keys case insensitive when getting faceting - // values with prefixes or contains; false otherwise. - bool case_insensitive = 6; - - // The order in which documents are returned. - // - // Allowed values are: - // - // * "count desc", which means order by - // [SearchResponse.Facet.values.count][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.count] - // descending. - // - // * "value desc", which means order by - // [SearchResponse.Facet.values.value][google.cloud.discoveryengine.v1beta.SearchResponse.Facet.FacetValue.value] - // descending. - // Only applies to textual facets. - // - // If not set, textual values are sorted in [natural - // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical - // intervals are sorted in the order given by - // [FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. - string order_by = 7; - } - - // Required. The facet key specification. - FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Maximum of facet values that should be returned for this facet. If - // unspecified, defaults to 20. The maximum allowed value is 300. Values - // above 300 will be coerced to 300. - // - // If this field is negative, an `INVALID_ARGUMENT` is returned. - int32 limit = 2; - - // List of keys to exclude when faceting. - // - // - // By default, - // [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] - // is not excluded from the filter unless it is listed in this field. - // - // Listing a facet key in this field allows its values to appear as facet - // results, even when they are filtered out of search results. Using this - // field does not affect what search results are returned. - // - // For example, suppose there are 100 documents with the color facet "Red" - // and 200 documents with the color facet "Blue". A query containing the - // filter "color:ANY("Red")" and having "color" as - // [FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key] - // would by default return only "Red" documents in the search results, and - // also return "Red" with count 100 as the only color facet. Although there - // are also blue documents available, "Blue" would not be shown as an - // available facet value. - // - // If "color" is listed in "excludedFilterKeys", then the query returns the - // facet values "Red" with count 100 and "Blue" with count 200, because the - // "color" key is now excluded from the filter. Because this field doesn't - // affect search results, the search results are still correctly filtered to - // return only "Red" documents. - // - // A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` - // error is returned. - repeated string excluded_filter_keys = 3; - - // Enables dynamic position for this facet. If set to true, the position of - // this facet among all facets in the response is determined automatically. - // It will be ordered together with dynamic facets if dynamic - // facets is enabled. If set to false, the position of this facet in the - // response will be the same as in the request, and it will be ranked before - // the facets with dynamic position enable and all dynamic facets. - // - // For example, you may always want to have rating facet returned in - // the response, but it's not necessarily to always display the rating facet - // at the top. In that case, you can set enable_dynamic_position to true so - // that the position of rating facet in response will be determined - // automatically. - // - // Another example, assuming you have the following facets in the request: - // - // * "rating", enable_dynamic_position = true - // - // * "price", enable_dynamic_position = false - // - // * "brands", enable_dynamic_position = false - // - // And also you have a dynamic facets enable, which will generate a facet - // 'gender'. Then the final order of the facets in the response can be - // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", - // "rating") depends on how API orders "gender" and "rating" facets. - // However, notice that "price" and "brands" will always be - // ranked at 1st and 2nd position since their enable_dynamic_position are - // false. - bool enable_dynamic_position = 4; - } - - // Boost specification to boost certain documents. - message BoostSpec { - // Boost applies to documents which match a condition. - message ConditionBoostSpec { - // An expression which specifies a boost condition. The syntax and - // supported fields are the same as a filter expression. See - // [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] - // for detail syntax and limitations. - // - // Examples: - // - // * To boost documents with document ID "doc_1" or "doc_2", and - // color - // "Red" or "Blue": - // * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue")) - string condition = 1; - - // Strength of the condition boost, which should be in [-1, 1]. Negative - // boost means demotion. Default is 0.0. - // - // Setting to 1.0 gives the document a big promotion. However, it does not - // necessarily mean that the boosted document will be the top result at - // all times, nor that other documents will be excluded. Results could - // still be shown even when none of them matches the condition. And - // results that are significantly more relevant to the search query can - // still trump your heavily favored but irrelevant documents. - // - // Setting to -1.0 gives the document a big demotion. However, results - // that are deeply relevant might still be shown. The document will have - // an upstream battle to get a fairly high ranking, but it is not blocked - // out completely. - // - // Setting to 0.0 means no boost applied. The boosting condition is - // ignored. - float boost = 2; - } - - // Condition boost specifications. If a document matches multiple conditions - // in the specifictions, boost scores from these specifications are all - // applied and combined in a non-linear way. Maximum number of - // specifications is 20. - repeated ConditionBoostSpec condition_boost_specs = 1; - } - - // Specification to determine under which conditions query expansion should - // occur. - message QueryExpansionSpec { - // Enum describing under which condition query expansion should occur. - enum Condition { - // Unspecified query expansion condition. In this case, server behavior - // defaults to - // [Condition.DISABLED][google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - CONDITION_UNSPECIFIED = 0; - - // Disabled query expansion. Only the exact search query is used, even if - // [SearchResponse.total_size][google.cloud.discoveryengine.v1beta.SearchResponse.total_size] - // is zero. - DISABLED = 1; - - // Automatic query expansion built by the Search API. - AUTO = 2; - } - - // The condition under which query expansion should occur. Default to - // [Condition.DISABLED][google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. - Condition condition = 1; - } - - // The specification for query spell correction. - message SpellCorrectionSpec { - // Enum describing under which mode spell correction should occur. - enum Mode { - // Unspecified spell correction mode. In this case, server behavior - // defaults to - // [Mode.AUTO][google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Search API will try to find a spell suggestion if there - // is any and put in the - // [SearchResponse.corrected_query][google.cloud.discoveryengine.v1beta.SearchResponse.corrected_query]. - // The spell suggestion will not be used as the search query. - SUGGESTION_ONLY = 1; - - // Automatic spell correction built by the Search API. Search will - // be based on the corrected query if found. - AUTO = 2; - } - - // The mode under which spell correction should take effect to - // replace the original search query. Default to - // [Mode.AUTO][google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. - Mode mode = 1; - } - - // The specification that configs the desired behavior of the UCS content - // search. - message ContentSearchSpec { - // The specification that configs the snippet in the search results. - message SnippetSpec { - // Max number of snippets returned in each search result. - // - // A snippet is an infomartive summary of a content with highlighting for - // UI rendering. - // - // If the matching snippets is less than the max_snippet_count, return all - // of the snippets; otherwise, return the max_snippet_count. - // - // At most 5 snippets will be returned for each SearchResult. - int32 max_snippet_count = 1; - - // if true, only snippet reference is returned. - bool reference_only = 2; - } - - // The specification that configs the summary in the search response. - message SummarySpec { - // The number of top results the summary should be generated from. - // If the number of returned results is less than summary_result_count, - // then the summary would be derived from all the results; otherwise, the - // summary would be derived from the top results. - // - // At most 5 results can be used for generating summary. - int32 summary_result_count = 1; - } - - // The specification that configs the extractive content in search results. - message ExtractiveContentSpec { - // The max number of extractive answers returned in each search result. - // - // An extractive answer is a verbatim answer extracted from the original - // document, which provides precise and contextually relevant answer to - // the search query. - // - // If the number of matching answers is less than the - // extractive_answer_count, return all of the answers; otherwise, return - // the extractive_answer_count. - // - // At most 5 answers will be returned for each SearchResult. - int32 max_extractive_answer_count = 1; - - // The max number of extractive segments returned in each search result. - // - // An extractive segment is a text segment extracted from the original - // document which is relevant to the search query and in general more - // verbose than an extrative answer. The segment could then be used as - // input for LLMs to generate summaries and answers. - // - // If the number of matching segments is less than the - // max_extractive_segment_count, return all of the segments; otherwise, - // return the max_extractive_segment_count. - // - // Currently one segment will be returned for each SearchResult. - int32 max_extractive_segment_count = 2; - } - - // If there is no snippet spec provided, there will be no snippet in the - // search result. - SnippetSpec snippet_spec = 1; - - // If there is no summary spec provided, there will be no summary in the - // search response. - SummarySpec summary_spec = 2; - - // If there is no extractive_content_spec provided, there will be no - // extractive answer in the search response. - ExtractiveContentSpec extractive_content_spec = 3; - } - - // Required. The resource name of the Search serving config, such as - // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. - // This field is used to identify the serving configuration name, set - // of models used to make the search. - string serving_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/ServingConfig" - } - ]; - - // The branch resource name, such as - // `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. - // - // Use `default_branch` as the branch ID or leave this field empty, to search - // documents under the default branch. - string branch = 2 [(google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Branch" - }]; - - // Raw search query. - string query = 3; - - // Maximum number of [Document][google.cloud.discoveryengine.v1beta.Document]s - // to return. If unspecified, defaults to a reasonable value. The maximum - // allowed value is 100. Values above 100 will be coerced to 100. - // - // If this field is negative, an `INVALID_ARGUMENT` is returned. - int32 page_size = 4; - - // A page token received from a previous - // [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] - // call. Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to - // [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] - // must match the call that provided the page token. Otherwise, an - // `INVALID_ARGUMENT` error is returned. - string page_token = 5; - - // A 0-indexed integer that specifies the current offset (that is, starting - // result location, amongst the - // [Document][google.cloud.discoveryengine.v1beta.Document]s deemed by the API - // as relevant) in search results. This field is only considered if - // [page_token][google.cloud.discoveryengine.v1beta.SearchRequest.page_token] - // is unset. - // - // If this field is negative, an `INVALID_ARGUMENT` is returned. - int32 offset = 6; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the documents being filtered. Filter - // expression is case-sensitive. - // - // If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. - string filter = 7; - - // The order in which documents are returned. Document can be ordered by - // a field in an [Document][google.cloud.discoveryengine.v1beta.Document] - // object. Leave it unset if ordered by relevance. OrderBy expression is - // case-sensitive. - // - // If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. - string order_by = 8; - - // Information about the end user. - // Highly recommended for analytics. The user_agent string in UserInfo will - // be used to deduce device_type for analytics. - UserInfo user_info = 21; - - // Facet specifications for faceted search. If empty, no facets are returned. - // - // A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` - // error is returned. - repeated FacetSpec facet_specs = 9; - - // Boost specification to boost certain documents. - BoostSpec boost_spec = 10; - - // Additional search parameters. - // - // For public website search only, supported values are: - // - // * `user_country_code`: string. Default empty. If set to non-empty, results - // are restricted or boosted based on the location provided. - // * `search_type`: double. Default empty. Enables non-webpage searching - // depending on the value. The only valid non-default value is 1, - // which enables image searching. - map params = 11; - - // The query expansion specification that specifies the conditions under which - // query expansion will occur. - QueryExpansionSpec query_expansion_spec = 13; - - // The spell correction specification that specifies the mode under - // which spell correction will take effect. - SpellCorrectionSpec spell_correction_spec = 14; - - // 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. - // - // This field should NOT have a fixed value such as `unknown_visitor`. - // - // This should be the same identifier as - // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] - // and - // [CompleteQueryRequest.user_pseudo_id][google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id] - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - string user_pseudo_id = 15; - - // The content search spec that configs the desired behavior of content - // search. - ContentSearchSpec content_search_spec = 24; - - // Whether to turn on safe search. This is only supported for - // [ContentConfig.PUBLIC_WEBSITE][]. - bool safe_search = 20; - - // The user 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. - map user_labels = 22; -} - -// Response message for -// [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] -// method. -message SearchResponse { - // Represents the search results. - message SearchResult { - // [Document.id][google.cloud.discoveryengine.v1beta.Document.id] of the - // searched [Document][google.cloud.discoveryengine.v1beta.Document]. - string id = 1; - - // The document data snippet in the search response. Only fields that are - // marked as retrievable are populated. - Document document = 2; - } - - // A facet result. - message Facet { - // A facet value which contains value names and their count. - message FacetValue { - // A facet value which contains values. - oneof facet_value { - // Text value of a facet, such as "Black" for facet "colors". - string value = 1; - - // Interval value for a facet, such as [10, 20) for facet "price". It - // matches - // [SearchRequest.FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.intervals]. - Interval interval = 2; - } - - // Number of items that have this facet value. - int64 count = 3; - } - - // The key for this facet. E.g., "colors" or "price". It matches - // [SearchRequest.FacetSpec.FacetKey.key][google.cloud.discoveryengine.v1beta.SearchRequest.FacetSpec.FacetKey.key]. - string key = 1; - - // The facet values for this field. - repeated FacetValue values = 2; - - // Whether the facet is dynamically generated. - bool dynamic_facet = 3; - } - - // Guided search result. The guided search helps user to refine the search - // results and narrow down to the real needs from a broaded search results. - message GuidedSearchResult { - // Useful attribute for search result refinements. - message RefinementAttribute { - // Attribute key used to refine the results e.g. 'movie_type'. - string attribute_key = 1; - - // Attribute value used to refine the results e.g. 'drama'. - string attribute_value = 2; - } - - // A list of ranked refinement attributes. - repeated RefinementAttribute refinement_attributes = 1; - } - - // Summary of the top N search result specified by the summary spec. - message Summary { - // The summary content. - string summary_text = 1; - } - - // A list of matched documents. The order represents the ranking. - repeated SearchResult results = 1; - - // Results of facets requested by user. - repeated Facet facets = 2; - - // Guided search result. - GuidedSearchResult guided_search_result = 8; - - // The estimated total count of matched items irrespective of pagination. The - // count of - // [results][google.cloud.discoveryengine.v1beta.SearchResponse.results] - // returned by pagination may be less than the - // [total_size][google.cloud.discoveryengine.v1beta.SearchResponse.total_size] - // that matches. - int32 total_size = 3; - - // A unique search token. This should be included in the - // [UserEvent][google.cloud.discoveryengine.v1beta.UserEvent] logs resulting - // from this search, which enables accurate attribution of search model - // performance. - string attribution_token = 4; - - // The URI of a customer-defined redirect page. If redirect action is - // triggered, no search is performed, and only - // [redirect_uri][google.cloud.discoveryengine.v1beta.SearchResponse.redirect_uri] - // and - // [attribution_token][google.cloud.discoveryengine.v1beta.SearchResponse.attribution_token] - // are set in the response. - string redirect_uri = 12; - - // A token that can be sent as - // [SearchRequest.page_token][google.cloud.discoveryengine.v1beta.SearchRequest.page_token] - // to retrieve the next page. If this field is omitted, there are no - // subsequent pages. - string next_page_token = 5; - - // Contains the spell corrected query, if found. If the spell correction type - // is AUTOMATIC, then the search results are based on corrected_query. - // Otherwise the original query is used for search. - string corrected_query = 7; - - // A summary as part of the search results. - // This field is only returned if - // [SearchRequest.ContentSearchSpec.summary_spec][google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.summary_spec] - // is set. - Summary summary = 9; - - // Controls applied as part of the Control service. - repeated string applied_controls = 10; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event.proto deleted file mode 100644 index 4efcf7ca90e..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event.proto +++ /dev/null @@ -1,465 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1beta/common.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "UserEventProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// UserEvent captures all metadata information Discovery Engine API needs to -// know about how end users interact with customers' website. -message UserEvent { - // Required. User event type. Allowed values are: - // - // Generic values: - // - // * `search`: Search for Documents. - // * `view-item`: Detailed page view of a Document. - // * `view-item-list`: View of a panel or ordered list of Documents. - // * `view-home-page`: View of the home page. - // * `view-category-page`: View of a category page, e.g. Home > Men > Jeans - // - // Retail-related values: - // - // * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping - // * `purchase`: Purchase an item(s) - // - // Media-related values: - // - // * `media-play`: Start/resume watching a video, playing a song, etc. - // * `media-complete`: Finished or stopped midway through a video, song, etc. - string event_type = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. 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 log in/out of the website. - // - // Do not set the field to the same fixed ID for different users. This mixes - // the event history of those users together, which results in degraded model - // quality. - // - // The field must be a UTF-8 encoded string with a length limit of 128 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // The field should not contain PII or user-data. We recommend to use Google - // Analytics [Client - // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) - // for this field. - string user_pseudo_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Only required for - // [UserEventService.ImportUserEvents][google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents] - // method. Timestamp of when the user event happened. - google.protobuf.Timestamp event_time = 3; - - // Information about the end user. - UserInfo user_info = 4; - - // Should set to true if the request is made directly from the end user, in - // which case the - // [UserEvent.user_info.user_agent][google.cloud.discoveryengine.v1beta.UserInfo.user_agent] - // can be populated from the HTTP request. - // - // This flag should be set only if the API request is made directly from the - // end user such as a mobile app (and not if a gateway or a server is - // processing and pushing the user events). - // - // This should not be set when using the JavaScript tag in - // [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent]. - bool direct_user_request = 5; - - // A unique identifier for tracking a visitor session with a length limit of - // 128 bytes. A session is an aggregation of an end user behavior in a time - // span. - // - // A general guideline to populate the session_id: - // - // 1. If user has no activity for 30 min, a new session_id should be assigned. - // 2. The session_id should be unique across users, suggest use uuid or add - // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] - // as prefix. - string session_id = 6; - - // Page metadata such as categories and other critical information for certain - // event types such as `view-category-page`. - PageInfo page_info = 7; - - // Token to attribute an API response to user action(s) to trigger the event. - // - // Highly recommended for user events that are the result of - // [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. - // This field enables accurate attribution of recommendation model - // performance. - // - // The value must be one of: - // - // * [PredictResponse.attribution_token][] for events that are the result of - // [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. - // * [SearchResponse.attribution_token][google.cloud.discoveryengine.v1beta.SearchResponse.attribution_token] for events that are the result of - // [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search]. - // * [CompleteQueryResponse.attribution_token][] for events that are the - // result of - // [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery]. - // - // This token enables us to accurately attribute page view or conversion - // completion back to the event and the particular predict response containing - // this clicked/purchased product. If user clicks on product K in the - // recommendation results, pass [PredictResponse.attribution_token][] as a URL - // parameter to product K's page. When recording events on product K's page, - // log the [PredictResponse.attribution_token][] to this field. - string attribution_token = 8; - - // The filter syntax consists of an expression language for constructing a - // predicate from one or more fields of the documents being filtered. - // - // One example is for `search` events, the associated - // [SearchRequest][google.cloud.discoveryengine.v1beta.SearchRequest] may - // contain a filter expression in - // [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] - // conforming to https://google.aip.dev/160#filtering. - // - // Similarly, for `view-item-list` events that are generated from a - // [RecommendationService.RecommendRequest][], this field may be populated - // directly from [RecommendationService.RecommendRequest.filter][] conforming - // to https://google.aip.dev/160#filtering. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - string filter = 9; - - // List of Documents associated with this user event. - // - // This field is optional except for the following event types: - // - // * `view-item` - // * `add-to-cart` - // * `purchase` - // * `media-play` - // * `media-complete` - // - // In a `search` event, this field represents the documents returned to the - // end user on the current page (the end user may have not finished browsing - // the whole page yet). When a new page is returned to the end user, after - // pagination/filtering/ordering even for the same query, a new `search` event - // with different - // [UserEvent.documents][google.cloud.discoveryengine.v1beta.UserEvent.documents] - // is desired. - repeated DocumentInfo documents = 10; - - // Panel metadata associated with this user event. - PanelInfo panel = 11; - - // Search API details related to the event. - // - // This field should be set for `search` event. - SearchInfo search_info = 12; - - // CompleteQuery API details related to the event. - // - // This field should be set for `search` event when autocomplete function is - // enabled and the user clicks a suggestion for search. - CompletionInfo completion_info = 13; - - // The transaction metadata (if any) associated with this user event. - TransactionInfo transaction_info = 14; - - // A list of identifiers for the independent experiment groups this user event - // belongs to. This is used to distinguish between user events associated with - // different experiment setups on the customer end. - repeated string tag_ids = 15; - - // The promotion IDs if this is an event associated with promotions. - // Currently, this field is restricted to at most one ID. - repeated string promotion_ids = 16; - - // Extra user event features to include in the recommendation model. - // These attributes must NOT contain data that needs to be parsed or processed - // further, e.g. JSON or other encodings. - // - // If you provide custom attributes for ingested user events, also include - // them in the user events that you associate with prediction requests. Custom - // attribute formatting must be consistent between imported events and events - // provided with prediction requests. This lets the Discovery Engine API use - // those custom attributes when training models and serving predictions, which - // helps improve recommendation quality. - // - // This field needs to pass all below criteria, otherwise an - // `INVALID_ARGUMENT` error is returned: - // - // * The key must be a UTF-8 encoded string with a length limit of 5,000 - // characters. - // * For text attributes, at most 400 values are allowed. Empty values are not - // allowed. Each value must be a UTF-8 encoded string with a length limit of - // 256 characters. - // * For number attributes, at most 400 values are allowed. - // - // For product recommendations, an example of extra user information is - // ` traffic_channel`, which is how a user arrives at the site. Users can - // arrive - // at the site by coming to the site directly, coming through Google - // search, or in other ways. - map attributes = 17; - - // Media-specific info. - MediaInfo media_info = 18; -} - -// Detailed page information. -message PageInfo { - // A unique ID of a web page view. - // - // This should be kept the same for all user events triggered from the same - // pageview. For example, an item detail page view could trigger multiple - // events as the user is browsing the page. The `pageViewId` property should - // be kept the same for all these events so that they can be grouped together - // properly. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. - string pageview_id = 1; - - // The most specific category associated with a category page. - // - // To represent full path of category, use '>' sign to separate different - // hierarchies. If '>' is part of the category name, please replace it with - // other character(s). - // - // Category pages include special pages such as sales or promotions. For - // instance, a special sale page may have the category hierarchy: - // "pageCategory" : "Sales > 2017 Black Friday Deals". - // - // Required for `view-category-page` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - string page_category = 2; - - // Complete URL (window.location.href) of the user's current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. Maximum length 5,000 - // characters. - string uri = 3; - - // The referrer URL of the current page. - // - // When using the client side event reporting with JavaScript pixel and Google - // Tag Manager, this value is filled in automatically. However, some browser - // privacy restrictions may cause this field to be empty. - string referrer_uri = 4; -} - -// Detailed search information. -message SearchInfo { - // The user's search query. - // - // See - // [SearchRequest.query][google.cloud.discoveryengine.v1beta.SearchRequest.query] - // for definition. - // - // The value must be a UTF-8 encoded string with a length limit of 5,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // At least one of - // [search_query][google.cloud.discoveryengine.v1beta.SearchInfo.search_query] - // or - // [PageInfo.page_category][google.cloud.discoveryengine.v1beta.PageInfo.page_category] - // is required for `search` events. Other event types should not set this - // field. Otherwise, an INVALID_ARGUMENT error is returned. - string search_query = 1; - - // The order in which products are returned, if applicable. - // - // See - // [SearchRequest.order_by][google.cloud.discoveryengine.v1beta.SearchRequest.order_by] - // for definition and syntax. - // - // The value must be a UTF-8 encoded string with a length limit of 1,000 - // characters. Otherwise, an INVALID_ARGUMENT error is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - string order_by = 2; - - // An integer that specifies the current offset for pagination (the 0-indexed - // starting location, amongst the products deemed by the API as relevant). - // - // See - // [SearchRequest.offset][google.cloud.discoveryengine.v1beta.SearchRequest.offset] - // for definition. - // - // If this field is negative, an INVALID_ARGUMENT is returned. - // - // This can only be set for `search` events. Other event types should not set - // this field. Otherwise, an INVALID_ARGUMENT error is returned. - optional int32 offset = 3; -} - -// Detailed completion information including completion attribution token and -// clicked completion info. -message CompletionInfo { - // End user selected [CompleteQueryResponse.CompletionResult.suggestion][]. - string selected_suggestion = 1; - - // End user selected [CompleteQueryResponse.CompletionResult.suggestion][] - // position, starting from 0. - int32 selected_position = 2; -} - -// A transaction represents the entire purchase transaction. -message TransactionInfo { - // Required. Total non-zero value associated with the transaction. This value - // may include shipping, tax, or other adjustments to the total value that you - // want to include. - optional float value = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Currency code. Use three-character ISO-4217 code. - string currency = 2 [(google.api.field_behavior) = REQUIRED]; - - // The transaction ID with a length limit of 128 characters. - string transaction_id = 3; - - // All the taxes associated with the transaction. - optional float tax = 4; - - // All the costs associated with the products. These can be manufacturing - // costs, shipping expenses not borne by the end user, or any other costs, - // such that: - // - // * Profit = - // [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - - // [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - - // [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] - optional float cost = 5; - - // The total discount(s) value applied to this transaction. - // This figure should be excluded from - // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - // - // For example, if a user paid - // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - // amount, then nominal (pre-discount) value of the transaction is the sum of - // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - // and - // [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] - // - // This means that profit is calculated the same way, regardless of the - // discount value, and that - // [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] - // can be larger than - // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value]: - // - // * Profit = - // [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - - // [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - - // [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] - optional float discount_value = 6; -} - -// Detailed document information associated with a user event. -message DocumentInfo { - // A required descriptor of the associated - // [Document][google.cloud.discoveryengine.v1beta.Document]. - // - // * If [id][google.cloud.discoveryengine.v1beta.DocumentInfo.id] is - // specified, then the default values for - // `{location}`, `{collection_id}`, `{data_store_id}`, and `{branch_id}` are - // used when annotating with the stored Document. - // - // * If [name][google.cloud.discoveryengine.v1beta.DocumentInfo.name] is - // specified, then the provided values (default values allowed) for - // `{location}`, `{collection_id}`, `{data_store_id}`, and - // `{branch_id}` are used when annotating with the stored Document. - oneof document_descriptor { - // Required. The Document resource ID. - string id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The Document resource full name, of the form: - // `projects/{project_id}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}` - string name = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/Document" - } - ]; - } - - // Quantity of the Document associated with the user event. Defaults to 1. - // - // For example, this field will be 2 if two quantities of the same Document - // are involved in a `add-to-cart` event. - // - // Required for events of the following event types: - // - // * `add-to-cart` - // * `purchase` - optional int32 quantity = 3; - - // The promotion IDs associated with this Document. - // Currently, this field is restricted to at most one ID. - repeated string promotion_ids = 4; -} - -// Detailed panel information associated with a user event. -message PanelInfo { - // Required. The panel ID. - string panel_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // The display name of the panel. - string display_name = 3; - - // The ordered position of the panel, if shown to the user with other panels. - // If set, then - // [total_panels][google.cloud.discoveryengine.v1beta.PanelInfo.total_panels] - // must also be set. - optional int32 panel_position = 4; - - // The total number of panels, including this one, shown to the user. - // Must be set if - // [panel_position][google.cloud.discoveryengine.v1beta.PanelInfo.panel_position] - // is set. - optional int32 total_panels = 5; -} - -// Media-specific user event information. -message MediaInfo { - // The media progress time in seconds, if applicable. - // For example, if the end user has finished 90 seconds of a playback video, - // then [MediaInfo.media_progress_duration.seconds][Duration.seconds] should - // be set to 90. - google.protobuf.Duration media_progress_duration = 1; - - // Media progress should be computed using only the media_progress_duration - // relative to the media total length. - // - // This value must be between `[0, 1.0]` inclusive. - // - // If this is not a playback or the progress cannot be computed (e.g. ongoing - // livestream), this field should be unset. - optional float media_progress_percentage = 2; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event_service.proto b/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event_service.proto deleted file mode 100644 index de59b0c2faa..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/protos/google/cloud/discoveryengine/v1beta/user_event_service.proto +++ /dev/null @@ -1,133 +0,0 @@ -// 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 -// -// 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. - -syntax = "proto3"; - -package google.cloud.discoveryengine.v1beta; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/httpbody.proto"; -import "google/api/resource.proto"; -import "google/cloud/discoveryengine/v1beta/import_config.proto"; -import "google/cloud/discoveryengine/v1beta/user_event.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; -option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; -option java_multiple_files = true; -option java_outer_classname = "UserEventServiceProto"; -option java_package = "com.google.cloud.discoveryengine.v1beta"; -option objc_class_prefix = "DISCOVERYENGINE"; -option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; -option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; - -// Service for ingesting end user actions on a website to Discovery Engine API. -service UserEventService { - option (google.api.default_host) = "discoveryengine.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Writes a single user event. - rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*/locations/*/dataStores/*}/userEvents:write" - body: "user_event" - additional_bindings { - post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:write" - body: "user_event" - } - }; - } - - // Writes a single user event from the browser. This uses a GET request to - // due to browser restriction of POST-ing to a 3rd party domain. - // - // This method is used only by the Discovery Engine API JavaScript pixel and - // Google Tag Manager. Users should not call this method directly. - rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { - option (google.api.http) = { - get: "/v1beta/{parent=projects/*/locations/*/dataStores/*}/userEvents:collect" - additional_bindings { - get: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:collect" - } - }; - } - - // Bulk import of User events. Request processing might be - // synchronous. Events that already exist are skipped. - // Use this method for backfilling historical user events. - // - // Operation.response is of type ImportResponse. Note that it is - // possible for a subset of the items to be successfully inserted. - // Operation.metadata is of type ImportMetadata. - rpc ImportUserEvents(ImportUserEventsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta/{parent=projects/*/locations/*/dataStores/*}/userEvents:import" - body: "*" - additional_bindings { - post: "/v1beta/{parent=projects/*/locations/*/collections/*/dataStores/*}/userEvents:import" - body: "*" - } - }; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.discoveryengine.v1beta.ImportUserEventsResponse" - metadata_type: "google.cloud.discoveryengine.v1beta.ImportUserEventsMetadata" - }; - } -} - -// Request message for WriteUserEvent method. -message WriteUserEventRequest { - // Required. The parent DataStore resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // Required. User event to write. - optional UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // Required. The parent DataStore resource name, such as - // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "discoveryengine.googleapis.com/DataStore" - } - ]; - - // Required. URL encoded UserEvent proto with a length limit of 2,000,000 - // characters. - string user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // 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. - optional string uri = 3; - - // The event timestamp in milliseconds. This prevents browser caching of - // otherwise identical get requests. The name is abbreviated to reduce the - // payload bytes. - optional int64 ets = 4; -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/completion_service.complete_query.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/completion_service.complete_query.js deleted file mode 100644 index 9100d412b8a..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/completion_service.complete_query.js +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2023 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(dataStore, query) { - // [START discoveryengine_v1beta_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. The parent data store resource name for which the completion is - * performed, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store`. - */ - // const dataStore = 'abc123' - /** - * Required. The typeahead input used to fetch suggestions. Maximum length is - * 128 characters. - */ - // const query = 'abc123' - /** - * Selects data model of query suggestions for serving. Currently supported - * values: - * * `document` - Using suggestions generated from user-imported documents. - * * `search-history` - Using suggestions generated from the past history of - * SearchService.Search google.cloud.discoveryengine.v1beta.SearchService.Search - * API calls. Do not use it when there is no traffic for Search API. - * * `user-event` - Using suggestions generated from user-imported search - * events. - * * `document-completable` - Using suggestions taken directly from - * user-imported document fields marked as completable. - * Default values: - * * `document` is the default model for regular dataStores. - * * `search-history` is the default model for - * IndustryVertical.SITE_SEARCH google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH - * dataStores. - */ - // const queryModel = 'abc123' - /** - * 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. - * This field should NOT have a fixed value such as `unknown_visitor`. - * This should be the same identifier as - * UserEvent.user_pseudo_id google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id - * and - * SearchRequest.user_pseudo_id google.cloud.discoveryengine.v1beta.SearchRequest.user_pseudo_id. - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - */ - // const userPseudoId = 'abc123' - - // Imports the Discoveryengine library - const {CompletionServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new CompletionServiceClient(); - - async function callCompleteQuery() { - // Construct request - const request = { - dataStore, - query, - }; - - // Run request - const response = await discoveryengineClient.completeQuery(request); - console.log(response); - } - - callCompleteQuery(); - // [END discoveryengine_v1beta_generated_CompletionService_CompleteQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.create_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.create_document.js deleted file mode 100644 index e0c966b4a4a..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.create_document.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2023 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, document, documentId) { - // [START discoveryengine_v1beta_generated_DocumentService_CreateDocument_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 resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - */ - // const parent = 'abc123' - /** - * Required. The Document google.cloud.discoveryengine.v1beta.Document to - * create. - */ - // const document = {} - /** - * Required. The ID to use for the - * Document google.cloud.discoveryengine.v1beta.Document, which will become - * the final component of the - * Document.name google.cloud.discoveryengine.v1beta.Document.name. - * If the caller does not have permission to create the - * Document google.cloud.discoveryengine.v1beta.Document, regardless of - * whether or not it exists, a `PERMISSION_DENIED` error is returned. - * This field must be unique among all - * Document google.cloud.discoveryengine.v1beta.Document s with the same - * parent google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent. - * Otherwise, an `ALREADY_EXISTS` error is returned. - * This field must conform to RFC-1034 (https://tools.ietf.org/html/rfc1034) - * standard with a length limit of 63 characters. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - */ - // const documentId = 'abc123' - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callCreateDocument() { - // Construct request - const request = { - parent, - document, - documentId, - }; - - // Run request - const response = await discoveryengineClient.createDocument(request); - console.log(response); - } - - callCreateDocument(); - // [END discoveryengine_v1beta_generated_DocumentService_CreateDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.delete_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.delete_document.js deleted file mode 100644 index e51c6883909..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.delete_document.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_generated_DocumentService_DeleteDocument_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 - * Document google.cloud.discoveryengine.v1beta.Document, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - * If the caller does not have permission to delete the - * Document google.cloud.discoveryengine.v1beta.Document, regardless of - * whether or not it exists, a `PERMISSION_DENIED` error is returned. - * If the Document google.cloud.discoveryengine.v1beta.Document to delete - * does not exist, a `NOT_FOUND` error is returned. - */ - // const name = 'abc123' - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callDeleteDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await discoveryengineClient.deleteDocument(request); - console.log(response); - } - - callDeleteDocument(); - // [END discoveryengine_v1beta_generated_DocumentService_DeleteDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.get_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.get_document.js deleted file mode 100644 index 2cfdd06e7c3..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.get_document.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_generated_DocumentService_GetDocument_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 - * Document google.cloud.discoveryengine.v1beta.Document, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - * If the caller does not have permission to access the - * Document google.cloud.discoveryengine.v1beta.Document, regardless of - * whether or not it exists, a `PERMISSION_DENIED` error is returned. - * If the requested Document google.cloud.discoveryengine.v1beta.Document - * does not exist, a `NOT_FOUND` error is returned. - */ - // const name = 'abc123' - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callGetDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await discoveryengineClient.getDocument(request); - console.log(response); - } - - callGetDocument(); - // [END discoveryengine_v1beta_generated_DocumentService_GetDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.import_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.import_documents.js deleted file mode 100644 index d737f12f8d3..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.import_documents.js +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_generated_DocumentService_ImportDocuments_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 Inline source for the input content for documents. - */ - // const inlineSource = {} - /** - * Cloud Storage location for the input content. - */ - // const gcsSource = {} - /** - * BigQuery input source. - */ - // const bigquerySource = {} - /** - * Required. The parent branch resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Requires create/update permission. - */ - // const parent = 'abc123' - /** - * The desired location of errors incurred during the Import. - */ - // const errorConfig = {} - /** - * The mode of reconciliation between existing documents and the documents to - * be imported. Defaults to - * ReconciliationMode.INCREMENTAL google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL. - */ - // const reconciliationMode = {} - /** - * Whether to automatically generate IDs for the documents if absent. - * If set to `true`, - * Document.id google.cloud.discoveryengine.v1beta.Document.id s are - * automatically generated based on the hash of the payload, where IDs may not - * be consistent during multiple imports. In which case - * ReconciliationMode.FULL google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.FULL - * is highly recommended to avoid duplicate contents. If unset or set to - * `false`, Document.id google.cloud.discoveryengine.v1beta.Document.id s - * have to be specified using - * id_field google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.id_field, - * otherwises, documents without IDs will fail to be imported. - * Only set this field when using - * GcsSource google.cloud.discoveryengine.v1beta.GcsSource or - * BigQuerySource google.cloud.discoveryengine.v1beta.BigQuerySource, and - * when - * GcsSource.data_schema google.cloud.discoveryengine.v1beta.GcsSource.data_schema - * or - * BigQuerySource.data_schema google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema - * is `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown. - */ - // const autoGenerateIds = true - /** - * The field in the Cloud Storage and BigQuery sources that indicates the - * unique IDs of the documents. - * For GcsSource google.cloud.discoveryengine.v1beta.GcsSource it is the - * key of the JSON field. For instance, `my_id` for JSON `{"my_id": - * "some_uuid"}`. For - * BigQuerySource google.cloud.discoveryengine.v1beta.BigQuerySource it is - * the column name of the BigQuery table where the unique ids are stored. - * The values of the JSON field or the BigQuery column will be used as the - * Document.id google.cloud.discoveryengine.v1beta.Document.id s. The JSON - * field or the BigQuery column must be of string type, and the values must be - * set as valid strings conform to - * RFC-1034 (https://tools.ietf.org/html/rfc1034) with 1-63 characters. - * Otherwise, documents without valid IDs will fail to be imported. - * Only set this field when using - * GcsSource google.cloud.discoveryengine.v1beta.GcsSource or - * BigQuerySource google.cloud.discoveryengine.v1beta.BigQuerySource, and - * when - * GcsSource.data_schema google.cloud.discoveryengine.v1beta.GcsSource.data_schema - * or - * BigQuerySource.data_schema google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema - * is `custom`. And only set this field when - * auto_generate_ids google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.auto_generate_ids - * is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. - * If it is unset, a default value `_id` is used when importing from the - * allowed data sources. - */ - // const idField = 'abc123' - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callImportDocuments() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await discoveryengineClient.importDocuments(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportDocuments(); - // [END discoveryengine_v1beta_generated_DocumentService_ImportDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.list_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.list_documents.js deleted file mode 100644 index 8df3c1c231a..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.list_documents.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_generated_DocumentService_ListDocuments_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/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Use `default_branch` as the branch ID, to list documents under the default - * branch. - * If the caller does not have permission to list Documents s under this - * branch, regardless of whether or not this branch exists, a - * `PERMISSION_DENIED` error is returned. - */ - // const parent = 'abc123' - /** - * Maximum number of Document google.cloud.discoveryengine.v1beta.Document 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 - * ListDocumentsResponse.next_page_token google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token, - * received from a previous - * DocumentService.ListDocuments google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * DocumentService.ListDocuments google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - */ - // const pageToken = 'abc123' - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callListDocuments() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await discoveryengineClient.listDocumentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListDocuments(); - // [END discoveryengine_v1beta_generated_DocumentService_ListDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.purge_documents.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.purge_documents.js deleted file mode 100644 index 401b9486ac5..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.purge_documents.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_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 resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - */ - // const parent = 'abc123' - /** - * Required. Filter matching documents to purge. Only currently supported - * value is - * `*` (all items). - */ - // const filter = 'abc123' - /** - * Actually performs the purge. If `force` is set to false, return the - * expected purge count without deleting any documents. - */ - // const force = true - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callPurgeDocuments() { - // Construct request - const request = { - parent, - filter, - }; - - // Run request - const [operation] = await discoveryengineClient.purgeDocuments(request); - const [response] = await operation.promise(); - console.log(response); - } - - callPurgeDocuments(); - // [END discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.update_document.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.update_document.js deleted file mode 100644 index 30d95c05426..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/document_service.update_document.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 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(document) { - // [START discoveryengine_v1beta_generated_DocumentService_UpdateDocument_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 document to update/create. - * If the caller does not have permission to update the - * Document google.cloud.discoveryengine.v1beta.Document, regardless of - * whether or not it exists, a `PERMISSION_DENIED` error is returned. - * If the Document google.cloud.discoveryengine.v1beta.Document to update - * does not exist and - * allow_missing google.cloud.discoveryengine.v1beta.UpdateDocumentRequest.allow_missing - * is not set, a `NOT_FOUND` error is returned. - */ - // const document = {} - /** - * If set to true, and the - * Document google.cloud.discoveryengine.v1beta.Document is not found, a - * new Document google.cloud.discoveryengine.v1beta.Document will be - * created. - */ - // const allowMissing = true - - // Imports the Discoveryengine library - const {DocumentServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new DocumentServiceClient(); - - async function callUpdateDocument() { - // Construct request - const request = { - document, - }; - - // Run request - const response = await discoveryengineClient.updateDocument(request); - console.log(response); - } - - callUpdateDocument(); - // [END discoveryengine_v1beta_generated_DocumentService_UpdateDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/recommendation_service.recommend.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/recommendation_service.recommend.js deleted file mode 100644 index 334741b9a48..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/recommendation_service.recommend.js +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2023 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, userEvent) { - // [START discoveryengine_v1beta_generated_RecommendationService_Recommend_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: - * `projects/* /locations/global/collections/* /dataStores/* /servingConfigs/*` - * Before you can request recommendations from your model, you must create at - * least one serving config for it. - */ - // const servingConfig = 'abc123' - /** - * Required. Context about the user, what they are looking at and what action - * they took to trigger the Recommend 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.user_pseudo_id google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id - * or - * UserEvent.user_info.user_id google.cloud.discoveryengine.v1beta.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.user_pseudo_id google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id - * to a random unique ID and leave - * UserEvent.user_info.user_id google.cloud.discoveryengine.v1beta.UserInfo.user_id - * unset. - */ - // const userEvent = {} - /** - * Maximum number of results to return. Set this property - * to the number of recommendation 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 - /** - * Filter for restricting recommendation results with a length limit of 5,000 - * characters. Currently, only filter expressions on the `filter_tags` - * attribute is supported. - * Examples: - * * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))` - * * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))` - * If your filter blocks all results, the API will return generic - * (unfiltered) popular Documents. If you only want results strictly matching - * the filters, set `strictFiltering` to True in - * RecommendRequest.params google.cloud.discoveryengine.v1beta.RecommendRequest.params - * to receive empty results instead. - * Note that the API will never return - * Document google.cloud.discoveryengine.v1beta.Document s with - * `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices. - */ - // const filter = 'abc123' - /** - * Use validate only mode for this recommendation query. If set to true, a - * fake model will be used that returns arbitrary Document IDs. - * 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 recommendations. - * Allowed values: - * * `returnDocument`: Boolean. If set to true, the associated Document - * object will be returned in - * RecommendResponse.RecommendationResult.document google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document. - * * `returnScore`: Boolean. If set to true, the recommendation 'score' - * corresponding to each returned Document will be set in - * RecommendResponse.RecommendationResult.metadata google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata. - * The given 'score' indicates the probability of a Document conversion - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular Documents instead of empty if - * your filter blocks all recommendation results. - * * `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 recommendation results - * based on Document category. - */ - // const params = 1234 - /** - * The user 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 Requirements for - * labels (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - */ - // const userLabels = 1234 - - // Imports the Discoveryengine library - const {RecommendationServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new RecommendationServiceClient(); - - async function callRecommend() { - // Construct request - const request = { - servingConfig, - userEvent, - }; - - // Run request - const response = await discoveryengineClient.recommend(request); - console.log(response); - } - - callRecommend(); - // [END discoveryengine_v1beta_generated_RecommendationService_Recommend_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.create_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.create_schema.js deleted file mode 100644 index 0454db4f0eb..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.create_schema.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2023 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, schema, schemaId) { - // [START discoveryengine_v1beta_generated_SchemaService_CreateSchema_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 data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - */ - // const parent = 'abc123' - /** - * Required. The Schema google.cloud.discoveryengine.v1beta.Schema to - * create. - */ - // const schema = {} - /** - * Required. The ID to use for the - * Schema google.cloud.discoveryengine.v1beta.Schema, which will become the - * final component of the - * Schema.name google.cloud.discoveryengine.v1beta.Schema.name. - * This field should conform to - * RFC-1034 (https://tools.ietf.org/html/rfc1034) standard with a length - * limit of 63 characters. - */ - // const schemaId = 'abc123' - - // Imports the Discoveryengine library - const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new SchemaServiceClient(); - - async function callCreateSchema() { - // Construct request - const request = { - parent, - schema, - schemaId, - }; - - // Run request - const [operation] = await discoveryengineClient.createSchema(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateSchema(); - // [END discoveryengine_v1beta_generated_SchemaService_CreateSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.delete_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.delete_schema.js deleted file mode 100644 index 01e8dcd4bb6..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.delete_schema.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_generated_SchemaService_DeleteSchema_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 full resource name of the schema, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - */ - // const name = 'abc123' - - // Imports the Discoveryengine library - const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new SchemaServiceClient(); - - async function callDeleteSchema() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await discoveryengineClient.deleteSchema(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteSchema(); - // [END discoveryengine_v1beta_generated_SchemaService_DeleteSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.get_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.get_schema.js deleted file mode 100644 index d537a5aa94d..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.get_schema.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_generated_SchemaService_GetSchema_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 full resource name of the schema, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - */ - // const name = 'abc123' - - // Imports the Discoveryengine library - const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new SchemaServiceClient(); - - async function callGetSchema() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await discoveryengineClient.getSchema(request); - console.log(response); - } - - callGetSchema(); - // [END discoveryengine_v1beta_generated_SchemaService_GetSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.list_schemas.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.list_schemas.js deleted file mode 100644 index 6c9338fc60e..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.list_schemas.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_generated_SchemaService_ListSchemas_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 data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - */ - // const parent = 'abc123' - /** - * The maximum number of Schema google.cloud.discoveryengine.v1beta.Schema s - * to return. The service may return fewer than this value. - * If unspecified, at most 100 - * Schema google.cloud.discoveryengine.v1beta.Schema s will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - */ - // const pageSize = 1234 - /** - * A page token, received from a previous - * SchemaService.ListSchemas google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * SchemaService.ListSchemas google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas - * must match the call that provided the page token. - */ - // const pageToken = 'abc123' - - // Imports the Discoveryengine library - const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new SchemaServiceClient(); - - async function callListSchemas() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await discoveryengineClient.listSchemasAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListSchemas(); - // [END discoveryengine_v1beta_generated_SchemaService_ListSchemas_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.update_schema.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.update_schema.js deleted file mode 100644 index 54343865e4a..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/schema_service.update_schema.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2023 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(schema) { - // [START discoveryengine_v1beta_generated_SchemaService_UpdateSchema_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 Schema google.cloud.discoveryengine.v1beta.Schema to - * update. - */ - // const schema = {} - /** - * If set to true, and the - * Schema google.cloud.discoveryengine.v1beta.Schema is not found, a new - * Schema google.cloud.discoveryengine.v1beta.Schema will be created. In - * this situation, `update_mask` is ignored. - */ - // const allowMissing = true - - // Imports the Discoveryengine library - const {SchemaServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new SchemaServiceClient(); - - async function callUpdateSchema() { - // Construct request - const request = { - schema, - }; - - // Run request - const [operation] = await discoveryengineClient.updateSchema(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateSchema(); - // [END discoveryengine_v1beta_generated_SchemaService_UpdateSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/search_service.search.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/search_service.search.js deleted file mode 100644 index 0ff32021830..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/search_service.search.js +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_generated_SearchService_Search_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 Search serving config, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. - * This field is used to identify the serving configuration name, set - * of models used to make the search. - */ - // const servingConfig = 'abc123' - /** - * The branch resource name, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. - * Use `default_branch` as the branch ID or leave this field empty, to search - * documents under the default branch. - */ - // const branch = 'abc123' - /** - * Raw search query. - */ - // const query = 'abc123' - /** - * Maximum number of Document google.cloud.discoveryengine.v1beta.Document s - * to return. If unspecified, defaults to a reasonable value. The maximum - * allowed value is 100. Values above 100 will be coerced to 100. - * If this field is negative, an `INVALID_ARGUMENT` is returned. - */ - // const pageSize = 1234 - /** - * A page token received from a previous - * SearchService.Search google.cloud.discoveryengine.v1beta.SearchService.Search - * call. Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to - * SearchService.Search google.cloud.discoveryengine.v1beta.SearchService.Search - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - */ - // const pageToken = 'abc123' - /** - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * Document google.cloud.discoveryengine.v1beta.Document s deemed by the API - * as relevant) in search results. This field is only considered if - * page_token google.cloud.discoveryengine.v1beta.SearchRequest.page_token - * is unset. - * If this field is negative, an `INVALID_ARGUMENT` is returned. - */ - // const offset = 1234 - /** - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the documents being filtered. Filter - * expression is case-sensitive. - * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. - */ - // const filter = 'abc123' - /** - * The order in which documents are returned. Document can be ordered by - * a field in an Document google.cloud.discoveryengine.v1beta.Document - * object. Leave it unset if ordered by relevance. OrderBy expression is - * case-sensitive. - * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. - */ - // const orderBy = 'abc123' - /** - * Information about the end user. - * Highly recommended for analytics. The user_agent string in UserInfo will - * be used to deduce device_type for analytics. - */ - // const userInfo = {} - /** - * Facet specifications for faceted search. If empty, no facets are returned. - * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` - * error is returned. - */ - // const facetSpecs = 1234 - /** - * Boost specification to boost certain documents. - */ - // const boostSpec = {} - /** - * Additional search parameters. - * For public website search only, supported values are: - * * `user_country_code`: string. Default empty. If set to non-empty, results - * are restricted or boosted based on the location provided. - * * `search_type`: double. Default empty. Enables non-webpage searching - * depending on the value. The only valid non-default value is 1, - * which enables image searching. - */ - // const params = 1234 - /** - * The query expansion specification that specifies the conditions under which - * query expansion will occur. - */ - // const queryExpansionSpec = {} - /** - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - */ - // const spellCorrectionSpec = {} - /** - * 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. - * This field should NOT have a fixed value such as `unknown_visitor`. - * This should be the same identifier as - * UserEvent.user_pseudo_id google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id - * and - * CompleteQueryRequest.user_pseudo_id google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - */ - // const userPseudoId = 'abc123' - /** - * The content search spec that configs the desired behavior of content - * search. - */ - // const contentSearchSpec = {} - /** - * Whether to turn on safe search. This is only supported for - * ContentConfig.PUBLIC_WEBSITE . - */ - // const safeSearch = true - /** - * The user 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 userLabels = 1234 - - // Imports the Discoveryengine library - const {SearchServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new SearchServiceClient(); - - async function callSearch() { - // Construct request - const request = { - servingConfig, - }; - - // Run request - const iterable = await discoveryengineClient.searchAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearch(); - // [END discoveryengine_v1beta_generated_SearchService_Search_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json deleted file mode 100644 index 8ff518f4eac..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json +++ /dev/null @@ -1,947 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-discoveryengine", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.discoveryengine.v1beta", - "version": "v1beta" - } - ] - }, - "snippets": [ - { - "regionTag": "discoveryengine_v1beta_generated_CompletionService_CompleteQuery_async", - "title": "CompletionService completeQuery Sample", - "origin": "API_DEFINITION", - "description": " Completes the specified user input with keyword suggestions.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 93, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery", - "async": true, - "parameters": [ - { - "name": "data_store", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "query_model", - "type": "TYPE_STRING" - }, - { - "name": "user_pseudo_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1beta.CompleteQueryResponse", - "client": { - "shortName": "CompletionServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.CompletionServiceClient" - }, - "method": { - "shortName": "CompleteQuery", - "fullName": "google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery", - "service": { - "shortName": "CompletionService", - "fullName": "google.cloud.discoveryengine.v1beta.CompletionService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_DocumentService_GetDocument_async", - "title": "CompletionService getDocument Sample", - "origin": "API_DEFINITION", - "description": " Gets a [Document][google.cloud.discoveryengine.v1beta.Document].", - "canonical": true, - "file": "document_service.get_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDocument", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.GetDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1beta.Document", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" - }, - "method": { - "shortName": "GetDocument", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.GetDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_DocumentService_ListDocuments_async", - "title": "CompletionService listDocuments Sample", - "origin": "API_DEFINITION", - "description": " Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s.", - "canonical": true, - "file": "document_service.list_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 80, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListDocuments", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1beta.ListDocumentsResponse", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" - }, - "method": { - "shortName": "ListDocuments", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_DocumentService_CreateDocument_async", - "title": "CompletionService createDocument Sample", - "origin": "API_DEFINITION", - "description": " Creates a [Document][google.cloud.discoveryengine.v1beta.Document].", - "canonical": true, - "file": "document_service.create_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 78, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDocument", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.CreateDocument", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "document", - "type": ".google.cloud.discoveryengine.v1beta.Document" - }, - { - "name": "document_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1beta.Document", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" - }, - "method": { - "shortName": "CreateDocument", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.CreateDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_DocumentService_UpdateDocument_async", - "title": "CompletionService updateDocument Sample", - "origin": "API_DEFINITION", - "description": " Updates a [Document][google.cloud.discoveryengine.v1beta.Document].", - "canonical": true, - "file": "document_service.update_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateDocument", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.UpdateDocument", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.cloud.discoveryengine.v1beta.Document" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.discoveryengine.v1beta.Document", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" - }, - "method": { - "shortName": "UpdateDocument", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.UpdateDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_DocumentService_DeleteDocument_async", - "title": "CompletionService deleteDocument Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [Document][google.cloud.discoveryengine.v1beta.Document].", - "canonical": true, - "file": "document_service.delete_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteDocument", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.DeleteDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" - }, - "method": { - "shortName": "DeleteDocument", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.DeleteDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_DocumentService_ImportDocuments_async", - "title": "CompletionService importDocuments Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of multiple [Document][google.cloud.discoveryengine.v1beta.Document]s. Request processing may be synchronous. Non-existing items will be created. Note: It is possible for a subset of the [Document][google.cloud.discoveryengine.v1beta.Document]s to be successfully updated.", - "canonical": true, - "file": "document_service.import_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 128, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportDocuments", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.ImportDocuments", - "async": true, - "parameters": [ - { - "name": "inline_source", - "type": ".google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.InlineSource" - }, - { - "name": "gcs_source", - "type": ".google.cloud.discoveryengine.v1beta.GcsSource" - }, - { - "name": "bigquery_source", - "type": ".google.cloud.discoveryengine.v1beta.BigQuerySource" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "error_config", - "type": ".google.cloud.discoveryengine.v1beta.ImportErrorConfig" - }, - { - "name": "reconciliation_mode", - "type": ".google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode" - }, - { - "name": "auto_generate_ids", - "type": "TYPE_BOOL" - }, - { - "name": "id_field", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" - }, - "method": { - "shortName": "ImportDocuments", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.ImportDocuments", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_async", - "title": "CompletionService purgeDocuments Sample", - "origin": "API_DEFINITION", - "description": " Permanently deletes all selected [Document][google.cloud.discoveryengine.v1beta.Document]s in a branch. This process is asynchronous. Depending on the number of [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, this operation can take hours to complete. Before the delete operation completes, some [Document][google.cloud.discoveryengine.v1beta.Document]s might still be returned by [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument] or [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments]. To get a list of the [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, set [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force] to false.", - "canonical": true, - "file": "document_service.purge_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PurgeDocuments", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.PurgeDocuments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentServiceClient" - }, - "method": { - "shortName": "PurgeDocuments", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService.PurgeDocuments", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.discoveryengine.v1beta.DocumentService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_RecommendationService_Recommend_async", - "title": "CompletionService recommend Sample", - "origin": "API_DEFINITION", - "description": " Makes a recommendation, which requires a contextual user event.", - "canonical": true, - "file": "recommendation_service.recommend.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 149, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Recommend", - "fullName": "google.cloud.discoveryengine.v1beta.RecommendationService.Recommend", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.discoveryengine.v1beta.UserEvent" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "params", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "user_labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.discoveryengine.v1beta.RecommendResponse", - "client": { - "shortName": "RecommendationServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.RecommendationServiceClient" - }, - "method": { - "shortName": "Recommend", - "fullName": "google.cloud.discoveryengine.v1beta.RecommendationService.Recommend", - "service": { - "shortName": "RecommendationService", - "fullName": "google.cloud.discoveryengine.v1beta.RecommendationService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_SchemaService_GetSchema_async", - "title": "CompletionService getSchema Sample", - "origin": "API_DEFINITION", - "description": " Gets a [Schema][google.cloud.discoveryengine.v1beta.Schema].", - "canonical": true, - "file": "schema_service.get_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetSchema", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.GetSchema", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1beta.Schema", - "client": { - "shortName": "SchemaServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaServiceClient" - }, - "method": { - "shortName": "GetSchema", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.GetSchema", - "service": { - "shortName": "SchemaService", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_SchemaService_ListSchemas_async", - "title": "CompletionService listSchemas Sample", - "origin": "API_DEFINITION", - "description": " Gets a list of [Schema][google.cloud.discoveryengine.v1beta.Schema]s.", - "canonical": true, - "file": "schema_service.list_schemas.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListSchemas", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.discoveryengine.v1beta.ListSchemasResponse", - "client": { - "shortName": "SchemaServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaServiceClient" - }, - "method": { - "shortName": "ListSchemas", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas", - "service": { - "shortName": "SchemaService", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_SchemaService_CreateSchema_async", - "title": "CompletionService createSchema Sample", - "origin": "API_DEFINITION", - "description": " Creates a [Schema][google.cloud.discoveryengine.v1beta.Schema].", - "canonical": true, - "file": "schema_service.create_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateSchema", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.CreateSchema", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "schema", - "type": ".google.cloud.discoveryengine.v1beta.Schema" - }, - { - "name": "schema_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "SchemaServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaServiceClient" - }, - "method": { - "shortName": "CreateSchema", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.CreateSchema", - "service": { - "shortName": "SchemaService", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_SchemaService_UpdateSchema_async", - "title": "CompletionService updateSchema Sample", - "origin": "API_DEFINITION", - "description": " Updates a [Schema][google.cloud.discoveryengine.v1beta.Schema].", - "canonical": true, - "file": "schema_service.update_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateSchema", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.UpdateSchema", - "async": true, - "parameters": [ - { - "name": "schema", - "type": ".google.cloud.discoveryengine.v1beta.Schema" - }, - { - "name": "allow_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "SchemaServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaServiceClient" - }, - "method": { - "shortName": "UpdateSchema", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.UpdateSchema", - "service": { - "shortName": "SchemaService", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_SchemaService_DeleteSchema_async", - "title": "CompletionService deleteSchema Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [Schema][google.cloud.discoveryengine.v1beta.Schema].", - "canonical": true, - "file": "schema_service.delete_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteSchema", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.DeleteSchema", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "SchemaServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaServiceClient" - }, - "method": { - "shortName": "DeleteSchema", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService.DeleteSchema", - "service": { - "shortName": "SchemaService", - "fullName": "google.cloud.discoveryengine.v1beta.SchemaService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_SearchService_Search_async", - "title": "CompletionService search Sample", - "origin": "API_DEFINITION", - "description": " Performs a search.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 189, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Search", - "fullName": "google.cloud.discoveryengine.v1beta.SearchService.Search", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "branch", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "offset", - "type": "TYPE_INT32" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "user_info", - "type": ".google.cloud.discoveryengine.v1beta.UserInfo" - }, - { - "name": "facet_specs", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "boost_spec", - "type": ".google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec" - }, - { - "name": "params", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "query_expansion_spec", - "type": ".google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec" - }, - { - "name": "spell_correction_spec", - "type": ".google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec" - }, - { - "name": "user_pseudo_id", - "type": "TYPE_STRING" - }, - { - "name": "content_search_spec", - "type": ".google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec" - }, - { - "name": "safe_search", - "type": "TYPE_BOOL" - }, - { - "name": "user_labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.cloud.discoveryengine.v1beta.SearchResponse", - "client": { - "shortName": "SearchServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.SearchServiceClient" - }, - "method": { - "shortName": "Search", - "fullName": "google.cloud.discoveryengine.v1beta.SearchService.Search", - "service": { - "shortName": "SearchService", - "fullName": "google.cloud.discoveryengine.v1beta.SearchService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_UserEventService_WriteUserEvent_async", - "title": "CompletionService writeUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event.", - "canonical": true, - "file": "user_event_service.write_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.WriteUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": ".google.cloud.discoveryengine.v1beta.UserEvent" - } - ], - "resultType": ".google.cloud.discoveryengine.v1beta.UserEvent", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventServiceClient" - }, - "method": { - "shortName": "WriteUserEvent", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.WriteUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_UserEventService_CollectUserEvent_async", - "title": "CompletionService collectUserEvent Sample", - "origin": "API_DEFINITION", - "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Discovery Engine API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", - "canonical": true, - "file": "user_event_service.collect_user_event.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - } - ], - "resultType": ".google.api.HttpBody", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventServiceClient" - }, - "method": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventService" - } - } - } - }, - { - "regionTag": "discoveryengine_v1beta_generated_UserEventService_ImportUserEvents_async", - "title": "CompletionService importUserEvents Sample", - "origin": "API_DEFINITION", - "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", - "canonical": true, - "file": "user_event_service.import_user_events.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents", - "async": true, - "parameters": [ - { - "name": "inline_source", - "type": ".google.cloud.discoveryengine.v1beta.ImportUserEventsRequest.InlineSource" - }, - { - "name": "gcs_source", - "type": ".google.cloud.discoveryengine.v1beta.GcsSource" - }, - { - "name": "bigquery_source", - "type": ".google.cloud.discoveryengine.v1beta.BigQuerySource" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "error_config", - "type": ".google.cloud.discoveryengine.v1beta.ImportErrorConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "UserEventServiceClient", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventServiceClient" - }, - "method": { - "shortName": "ImportUserEvents", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents", - "service": { - "shortName": "UserEventService", - "fullName": "google.cloud.discoveryengine.v1beta.UserEventService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.collect_user_event.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.collect_user_event.js deleted file mode 100644 index c77b763bec4..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.collect_user_event.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_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 DataStore resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - */ - // 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 Discoveryengine library - const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new UserEventServiceClient(); - - async function callCollectUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await discoveryengineClient.collectUserEvent(request); - console.log(response); - } - - callCollectUserEvent(); - // [END discoveryengine_v1beta_generated_UserEventService_CollectUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.import_user_events.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.import_user_events.js deleted file mode 100644 index 536d06ef174..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.import_user_events.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_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. - */ - /** - * The Inline source for the input content for UserEvents. - */ - // const inlineSource = {} - /** - * Cloud Storage location for the input content. - */ - // const gcsSource = {} - /** - * BigQuery input source. - */ - // const bigquerySource = {} - /** - * Required. Parent DataStore resource name, of the form - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` - */ - // const parent = 'abc123' - /** - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - */ - // const errorConfig = {} - - // Imports the Discoveryengine library - const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new UserEventServiceClient(); - - async function callImportUserEvents() { - // Construct request - const request = { - parent, - }; - - // Run request - const [operation] = await discoveryengineClient.importUserEvents(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportUserEvents(); - // [END discoveryengine_v1beta_generated_UserEventService_ImportUserEvents_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.write_user_event.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.write_user_event.js deleted file mode 100644 index c8b43541973..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/samples/generated/v1beta/user_event_service.write_user_event.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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 discoveryengine_v1beta_generated_UserEventService_WriteUserEvent_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 DataStore resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - - // Imports the Discoveryengine library - const {UserEventServiceClient} = require('@google-cloud/discoveryengine').v1beta; - - // Instantiates a client - const discoveryengineClient = new UserEventServiceClient(); - - async function callWriteUserEvent() { - // Construct request - const request = { - parent, - userEvent, - }; - - // Run request - const response = await discoveryengineClient.writeUserEvent(request); - console.log(response); - } - - callWriteUserEvent(); - // [END discoveryengine_v1beta_generated_UserEventService_WriteUserEvent_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/index.ts deleted file mode 100644 index 29248adf6e4..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2023 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. ** - -import * as v1beta from './v1beta'; -const CompletionServiceClient = v1beta.CompletionServiceClient; -type CompletionServiceClient = v1beta.CompletionServiceClient; -const DocumentServiceClient = v1beta.DocumentServiceClient; -type DocumentServiceClient = v1beta.DocumentServiceClient; -const RecommendationServiceClient = v1beta.RecommendationServiceClient; -type RecommendationServiceClient = v1beta.RecommendationServiceClient; -const SchemaServiceClient = v1beta.SchemaServiceClient; -type SchemaServiceClient = v1beta.SchemaServiceClient; -const SearchServiceClient = v1beta.SearchServiceClient; -type SearchServiceClient = v1beta.SearchServiceClient; -const UserEventServiceClient = v1beta.UserEventServiceClient; -type UserEventServiceClient = v1beta.UserEventServiceClient; -export {v1beta, CompletionServiceClient, DocumentServiceClient, RecommendationServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient}; -export default {v1beta, CompletionServiceClient, DocumentServiceClient, RecommendationServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client.ts deleted file mode 100644 index e4a14f3c853..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client.ts +++ /dev/null @@ -1,856 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/completion_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './completion_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for Auto-Completion. - * @class - * @memberof v1beta - */ -export class CompletionServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - completionServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CompletionServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new CompletionServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CompletionServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' - ), - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1beta.CompletionService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.completionServiceStub) { - return this.completionServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1beta.CompletionService. - this.completionServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.CompletionService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1beta.CompletionService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const completionServiceStubMethods = - ['completeQuery']; - for (const methodName of completionServiceStubMethods) { - const callPromise = this.completionServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.completionServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Completes the specified user input with keyword suggestions. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.dataStore - * Required. The parent data store resource name for which the completion is - * performed, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store`. - * @param {string} request.query - * Required. The typeahead input used to fetch suggestions. Maximum length is - * 128 characters. - * @param {string} request.queryModel - * Selects data model of query suggestions for serving. Currently supported - * values: - * - * * `document` - Using suggestions generated from user-imported documents. - * * `search-history` - Using suggestions generated from the past history of - * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} - * API calls. Do not use it when there is no traffic for Search API. - * * `user-event` - Using suggestions generated from user-imported search - * events. - * * `document-completable` - Using suggestions taken directly from - * user-imported document fields marked as completable. - * - * Default values: - * - * * `document` is the default model for regular dataStores. - * * `search-history` is the default model for - * {@link google.cloud.discoveryengine.v1beta.IndustryVertical.SITE_SEARCH|IndustryVertical.SITE_SEARCH} - * dataStores. - * @param {string} request.userPseudoId - * 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. - * - * This field should NOT have a fixed value such as `unknown_visitor`. - * - * This should be the same identifier as - * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} - * and - * {@link google.cloud.discoveryengine.v1beta.SearchRequest.user_pseudo_id|SearchRequest.user_pseudo_id}. - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.CompleteQueryResponse | CompleteQueryResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta/completion_service.complete_query.js - * region_tag:discoveryengine_v1beta_generated_CompletionService_CompleteQuery_async - */ - completeQuery( - request?: protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|undefined, {}|undefined - ]>; - completeQuery( - request: protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request: protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; - completeQuery( - request?: protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse, - protos.google.cloud.discoveryengine.v1beta.ICompleteQueryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'data_store': request.dataStore ?? '', - }); - this.initialize(); - return this.innerApiCalls.completeQuery(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationDataStorePath(project:string,location:string,dataStore:string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.completionServiceStub && !this._terminated) { - return this.completionServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client_config.json deleted file mode 100644 index 9839a098d04..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_client_config.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1beta.CompletionService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CompleteQuery": { - "timeout_millis": 5000, - "retry_codes_name": "unavailable", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_proto_list.json deleted file mode 100644 index c90e69baf40..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/completion_service_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1beta/common.proto", - "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client.ts deleted file mode 100644 index 0b1ab721514..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client.ts +++ /dev/null @@ -1,1845 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/document_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './document_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting - * {@link google.cloud.discoveryengine.v1beta.Document|Document} information of the - * customer's website. - * @class - * @memberof v1beta - */ -export class DocumentServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - documentServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DocumentServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new DocumentServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DocumentServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}' - ), - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listDocuments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{get: '/v1beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*}/operations',},{get: '/v1beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importDocumentsResponse = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.ImportDocumentsResponse') as gax.protobuf.Type; - const importDocumentsMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.ImportDocumentsMetadata') as gax.protobuf.Type; - const purgeDocumentsResponse = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.PurgeDocumentsResponse') as gax.protobuf.Type; - const purgeDocumentsMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.PurgeDocumentsMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importDocumentsResponse.decode.bind(importDocumentsResponse), - importDocumentsMetadata.decode.bind(importDocumentsMetadata)), - purgeDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - purgeDocumentsResponse.decode.bind(purgeDocumentsResponse), - purgeDocumentsMetadata.decode.bind(purgeDocumentsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1beta.DocumentService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.documentServiceStub) { - return this.documentServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1beta.DocumentService. - this.documentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.DocumentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1beta.DocumentService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const documentServiceStubMethods = - ['getDocument', 'listDocuments', 'createDocument', 'updateDocument', 'deleteDocument', 'importDocuments', 'purgeDocuments']; - for (const methodName of documentServiceStubMethods) { - const callPromise = this.documentServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.documentServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets a {@link google.cloud.discoveryengine.v1beta.Document|Document}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.discoveryengine.v1beta.Document|Document}, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - * - * If the caller does not have permission to access the - * {@link google.cloud.discoveryengine.v1beta.Document|Document}, regardless of - * whether or not it exists, a `PERMISSION_DENIED` error is returned. - * - * If the requested {@link google.cloud.discoveryengine.v1beta.Document|Document} - * does not exist, a `NOT_FOUND` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.Document | Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta/document_service.get_document.js - * region_tag:discoveryengine_v1beta_generated_DocumentService_GetDocument_async - */ - getDocument( - request?: protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|undefined, {}|undefined - ]>; - getDocument( - request: protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|null|undefined, - {}|null|undefined>): void; - getDocument( - request: protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|null|undefined, - {}|null|undefined>): void; - getDocument( - request?: protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IGetDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getDocument(request, options, callback); - } -/** - * Creates a {@link google.cloud.discoveryengine.v1beta.Document|Document}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * @param {google.cloud.discoveryengine.v1beta.Document} request.document - * Required. The {@link google.cloud.discoveryengine.v1beta.Document|Document} to - * create. - * @param {string} request.documentId - * Required. The ID to use for the - * {@link google.cloud.discoveryengine.v1beta.Document|Document}, which will become - * the final component of the - * {@link google.cloud.discoveryengine.v1beta.Document.name|Document.name}. - * - * If the caller does not have permission to create the - * {@link google.cloud.discoveryengine.v1beta.Document|Document}, regardless of - * whether or not it exists, a `PERMISSION_DENIED` error is returned. - * - * This field must be unique among all - * {@link google.cloud.discoveryengine.v1beta.Document|Document}s with the same - * {@link google.cloud.discoveryengine.v1beta.CreateDocumentRequest.parent|parent}. - * Otherwise, an `ALREADY_EXISTS` error is returned. - * - * This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) - * standard with a length limit of 63 characters. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.Document | Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta/document_service.create_document.js - * region_tag:discoveryengine_v1beta_generated_DocumentService_CreateDocument_async - */ - createDocument( - request?: protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|undefined, {}|undefined - ]>; - createDocument( - request: protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): void; - createDocument( - request: protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): void; - createDocument( - request?: protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.ICreateDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createDocument(request, options, callback); - } -/** - * Updates a {@link google.cloud.discoveryengine.v1beta.Document|Document}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.discoveryengine.v1beta.Document} request.document - * Required. The document to update/create. - * - * If the caller does not have permission to update the - * {@link google.cloud.discoveryengine.v1beta.Document|Document}, regardless of - * whether or not it exists, a `PERMISSION_DENIED` error is returned. - * - * If the {@link google.cloud.discoveryengine.v1beta.Document|Document} to update - * does not exist and - * {@link google.cloud.discoveryengine.v1beta.UpdateDocumentRequest.allow_missing|allow_missing} - * is not set, a `NOT_FOUND` error is returned. - * @param {boolean} request.allowMissing - * If set to true, and the - * {@link google.cloud.discoveryengine.v1beta.Document|Document} is not found, a - * new {@link google.cloud.discoveryengine.v1beta.Document|Document} will be - * created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.Document | Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta/document_service.update_document.js - * region_tag:discoveryengine_v1beta_generated_DocumentService_UpdateDocument_async - */ - updateDocument( - request?: protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|undefined, {}|undefined - ]>; - updateDocument( - request: protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): void; - updateDocument( - request: protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): void; - updateDocument( - request?: protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IDocument, - protos.google.cloud.discoveryengine.v1beta.IUpdateDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'document.name': request.document!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateDocument(request, options, callback); - } -/** - * Deletes a {@link google.cloud.discoveryengine.v1beta.Document|Document}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Full resource name of - * {@link google.cloud.discoveryengine.v1beta.Document|Document}, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. - * - * If the caller does not have permission to delete the - * {@link google.cloud.discoveryengine.v1beta.Document|Document}, regardless of - * whether or not it exists, a `PERMISSION_DENIED` error is returned. - * - * If the {@link google.cloud.discoveryengine.v1beta.Document|Document} to delete - * does not exist, a `NOT_FOUND` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.protobuf.Empty | Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta/document_service.delete_document.js - * region_tag:discoveryengine_v1beta_generated_DocumentService_DeleteDocument_async - */ - deleteDocument( - request?: protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|undefined, {}|undefined - ]>; - deleteDocument( - request: protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): void; - deleteDocument( - request: protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): void; - deleteDocument( - request?: protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.discoveryengine.v1beta.IDeleteDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteDocument(request, options, callback); - } - -/** - * Bulk import of multiple - * {@link google.cloud.discoveryengine.v1beta.Document|Document}s. Request - * processing may be synchronous. Non-existing items will be created. - * - * Note: It is possible for a subset of the - * {@link google.cloud.discoveryengine.v1beta.Document|Document}s to be - * successfully updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.InlineSource} request.inlineSource - * The Inline source for the input content for documents. - * @param {google.cloud.discoveryengine.v1beta.GcsSource} request.gcsSource - * Cloud Storage location for the input content. - * @param {google.cloud.discoveryengine.v1beta.BigQuerySource} request.bigquerySource - * BigQuery input source. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Requires create/update permission. - * @param {google.cloud.discoveryengine.v1beta.ImportErrorConfig} request.errorConfig - * The desired location of errors incurred during the Import. - * @param {google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode} request.reconciliationMode - * The mode of reconciliation between existing documents and the documents to - * be imported. Defaults to - * {@link google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. - * @param {boolean} request.autoGenerateIds - * Whether to automatically generate IDs for the documents if absent. - * - * If set to `true`, - * {@link google.cloud.discoveryengine.v1beta.Document.id|Document.id}s are - * automatically generated based on the hash of the payload, where IDs may not - * be consistent during multiple imports. In which case - * {@link google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.ReconciliationMode.FULL|ReconciliationMode.FULL} - * is highly recommended to avoid duplicate contents. If unset or set to - * `false`, {@link google.cloud.discoveryengine.v1beta.Document.id|Document.id}s - * have to be specified using - * {@link google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.id_field|id_field}, - * otherwises, documents without IDs will fail to be imported. - * - * Only set this field when using - * {@link google.cloud.discoveryengine.v1beta.GcsSource|GcsSource} or - * {@link google.cloud.discoveryengine.v1beta.BigQuerySource|BigQuerySource}, and - * when - * {@link google.cloud.discoveryengine.v1beta.GcsSource.data_schema|GcsSource.data_schema} - * or - * {@link google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema|BigQuerySource.data_schema} - * is `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown. - * @param {string} request.idField - * The field in the Cloud Storage and BigQuery sources that indicates the - * unique IDs of the documents. - * - * For {@link google.cloud.discoveryengine.v1beta.GcsSource|GcsSource} it is the - * key of the JSON field. For instance, `my_id` for JSON `{"my_id": - * "some_uuid"}`. For - * {@link google.cloud.discoveryengine.v1beta.BigQuerySource|BigQuerySource} it is - * the column name of the BigQuery table where the unique ids are stored. - * - * The values of the JSON field or the BigQuery column will be used as the - * {@link google.cloud.discoveryengine.v1beta.Document.id|Document.id}s. The JSON - * field or the BigQuery column must be of string type, and the values must be - * set as valid strings conform to - * [RFC-1034](https://tools.ietf.org/html/rfc1034) with 1-63 characters. - * Otherwise, documents without valid IDs will fail to be imported. - * - * Only set this field when using - * {@link google.cloud.discoveryengine.v1beta.GcsSource|GcsSource} or - * {@link google.cloud.discoveryengine.v1beta.BigQuerySource|BigQuerySource}, and - * when - * {@link google.cloud.discoveryengine.v1beta.GcsSource.data_schema|GcsSource.data_schema} - * or - * {@link google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema|BigQuerySource.data_schema} - * is `custom`. And only set this field when - * {@link google.cloud.discoveryengine.v1beta.ImportDocumentsRequest.auto_generate_ids|auto_generate_ids} - * is unset or set as `false`. Otherwise, an INVALID_ARGUMENT error is thrown. - * - * If it is unset, a default value `_id` is used when importing from the - * allowed data sources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/document_service.import_documents.js - * region_tag:discoveryengine_v1beta_generated_DocumentService_ImportDocuments_async - */ - importDocuments( - request?: protos.google.cloud.discoveryengine.v1beta.IImportDocumentsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importDocuments( - request: protos.google.cloud.discoveryengine.v1beta.IImportDocumentsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importDocuments( - request: protos.google.cloud.discoveryengine.v1beta.IImportDocumentsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importDocuments( - request?: protos.google.cloud.discoveryengine.v1beta.IImportDocumentsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.importDocuments(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importDocuments()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/document_service.import_documents.js - * region_tag:discoveryengine_v1beta_generated_DocumentService_ImportDocuments_async - */ - async checkImportDocumentsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importDocuments, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Permanently deletes all selected - * {@link google.cloud.discoveryengine.v1beta.Document|Document}s in a branch. - * - * This process is asynchronous. Depending on the number of - * {@link google.cloud.discoveryengine.v1beta.Document|Document}s to be deleted, - * this operation can take hours to complete. Before the delete operation - * completes, some {@link google.cloud.discoveryengine.v1beta.Document|Document}s - * might still be returned by - * {@link google.cloud.discoveryengine.v1beta.DocumentService.GetDocument|DocumentService.GetDocument} - * or - * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments}. - * - * To get a list of the - * {@link google.cloud.discoveryengine.v1beta.Document|Document}s to be deleted, - * set - * {@link google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force|PurgeDocumentsRequest.force} - * to false. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * @param {string} request.filter - * Required. Filter matching documents to purge. Only currently supported - * value is - * `*` (all items). - * @param {boolean} request.force - * Actually performs the purge. If `force` is set to false, return the - * expected purge count without deleting any documents. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/document_service.purge_documents.js - * region_tag:discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_async - */ - purgeDocuments( - request?: protos.google.cloud.discoveryengine.v1beta.IPurgeDocumentsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - purgeDocuments( - request: protos.google.cloud.discoveryengine.v1beta.IPurgeDocumentsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeDocuments( - request: protos.google.cloud.discoveryengine.v1beta.IPurgeDocumentsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - purgeDocuments( - request?: protos.google.cloud.discoveryengine.v1beta.IPurgeDocumentsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.purgeDocuments(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeDocuments()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/document_service.purge_documents.js - * region_tag:discoveryengine_v1beta_generated_DocumentService_PurgeDocuments_async - */ - async checkPurgeDocumentsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeDocuments, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Gets a list of {@link google.cloud.discoveryengine.v1beta.Document|Document}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Use `default_branch` as the branch ID, to list documents under the default - * branch. - * - * If the caller does not have permission to list {@link |Documents}s under this - * branch, regardless of whether or not this branch exists, a - * `PERMISSION_DENIED` error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}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. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link google.cloud.discoveryengine.v1beta.Document | Document}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDocumentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDocuments( - request?: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IDocument[], - protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest|null, - protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse - ]>; - listDocuments( - request: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, - protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.IDocument>): void; - listDocuments( - request: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, - protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.IDocument>): void; - listDocuments( - request?: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, - protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.IDocument>, - callback?: PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, - protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.IDocument>): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IDocument[], - protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest|null, - protos.google.cloud.discoveryengine.v1beta.IListDocumentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listDocuments(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Use `default_branch` as the branch ID, to list documents under the default - * branch. - * - * If the caller does not have permission to list {@link |Documents}s under this - * branch, regardless of whether or not this branch exists, a - * `PERMISSION_DENIED` error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}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. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1beta.Document | Document} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDocumentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDocumentsStream( - request?: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.createStream( - this.innerApiCalls.listDocuments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listDocuments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent branch resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}`. - * Use `default_branch` as the branch ID, to list documents under the default - * branch. - * - * If the caller does not have permission to list {@link |Documents}s under this - * branch, regardless of whether or not this branch exists, a - * `PERMISSION_DENIED` error is returned. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}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. - * @param {string} request.pageToken - * A page token - * {@link google.cloud.discoveryengine.v1beta.ListDocumentsResponse.next_page_token|ListDocumentsResponse.next_page_token}, - * received from a previous - * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments|DocumentService.ListDocuments} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.discoveryengine.v1beta.Document | Document}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1beta/document_service.list_documents.js - * region_tag:discoveryengine_v1beta_generated_DocumentService_ListDocuments_async - */ - listDocumentsAsync( - request?: protos.google.cloud.discoveryengine.v1beta.IListDocumentsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.asyncIterate( - this.innerApiCalls['listDocuments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchPath(project:string,location:string,collection:string,dataStore:string,branch:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).branch; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchPath(project:string,location:string,dataStore:string,branch:string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).branch; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.documentServiceStub && !this._terminated) { - return this.documentServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client_config.json deleted file mode 100644 index 386e18b5201..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_client_config.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1beta.DocumentService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "GetDocument": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListDocuments": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "CreateDocument": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateDocument": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "DeleteDocument": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ImportDocuments": { - "timeout_millis": 300000, - "retry_codes_name": "unavailable", - "retry_params_name": "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876" - }, - "PurgeDocuments": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_proto_list.json deleted file mode 100644 index c90e69baf40..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/document_service_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1beta/common.proto", - "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/gapic_metadata.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/gapic_metadata.json deleted file mode 100644 index e5bab29651f..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/gapic_metadata.json +++ /dev/null @@ -1,285 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.discoveryengine.v1beta", - "libraryPackage": "@google-cloud/discoveryengine", - "services": { - "CompletionService": { - "clients": { - "grpc": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CompletionServiceClient", - "rpcs": { - "CompleteQuery": { - "methods": [ - "completeQuery" - ] - } - } - } - } - }, - "DocumentService": { - "clients": { - "grpc": { - "libraryClient": "DocumentServiceClient", - "rpcs": { - "GetDocument": { - "methods": [ - "getDocument" - ] - }, - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, - "UpdateDocument": { - "methods": [ - "updateDocument" - ] - }, - "DeleteDocument": { - "methods": [ - "deleteDocument" - ] - }, - "ImportDocuments": { - "methods": [ - "importDocuments" - ] - }, - "PurgeDocuments": { - "methods": [ - "purgeDocuments" - ] - }, - "ListDocuments": { - "methods": [ - "listDocuments", - "listDocumentsStream", - "listDocumentsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentServiceClient", - "rpcs": { - "GetDocument": { - "methods": [ - "getDocument" - ] - }, - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, - "UpdateDocument": { - "methods": [ - "updateDocument" - ] - }, - "DeleteDocument": { - "methods": [ - "deleteDocument" - ] - }, - "ImportDocuments": { - "methods": [ - "importDocuments" - ] - }, - "PurgeDocuments": { - "methods": [ - "purgeDocuments" - ] - }, - "ListDocuments": { - "methods": [ - "listDocuments", - "listDocumentsStream", - "listDocumentsAsync" - ] - } - } - } - } - }, - "RecommendationService": { - "clients": { - "grpc": { - "libraryClient": "RecommendationServiceClient", - "rpcs": { - "Recommend": { - "methods": [ - "recommend" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RecommendationServiceClient", - "rpcs": { - "Recommend": { - "methods": [ - "recommend" - ] - } - } - } - } - }, - "SchemaService": { - "clients": { - "grpc": { - "libraryClient": "SchemaServiceClient", - "rpcs": { - "GetSchema": { - "methods": [ - "getSchema" - ] - }, - "CreateSchema": { - "methods": [ - "createSchema" - ] - }, - "UpdateSchema": { - "methods": [ - "updateSchema" - ] - }, - "DeleteSchema": { - "methods": [ - "deleteSchema" - ] - }, - "ListSchemas": { - "methods": [ - "listSchemas", - "listSchemasStream", - "listSchemasAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SchemaServiceClient", - "rpcs": { - "GetSchema": { - "methods": [ - "getSchema" - ] - }, - "CreateSchema": { - "methods": [ - "createSchema" - ] - }, - "UpdateSchema": { - "methods": [ - "updateSchema" - ] - }, - "DeleteSchema": { - "methods": [ - "deleteSchema" - ] - }, - "ListSchemas": { - "methods": [ - "listSchemas", - "listSchemasStream", - "listSchemasAsync" - ] - } - } - } - } - }, - "SearchService": { - "clients": { - "grpc": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SearchServiceClient", - "rpcs": { - "Search": { - "methods": [ - "search", - "searchStream", - "searchAsync" - ] - } - } - } - } - }, - "UserEventService": { - "clients": { - "grpc": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "UserEventServiceClient", - "rpcs": { - "WriteUserEvent": { - "methods": [ - "writeUserEvent" - ] - }, - "CollectUserEvent": { - "methods": [ - "collectUserEvent" - ] - }, - "ImportUserEvents": { - "methods": [ - "importUserEvents" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/index.ts deleted file mode 100644 index 5f42e7b32db..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2023 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. ** - -export {CompletionServiceClient} from './completion_service_client'; -export {DocumentServiceClient} from './document_service_client'; -export {RecommendationServiceClient} from './recommendation_service_client'; -export {SchemaServiceClient} from './schema_service_client'; -export {SearchServiceClient} from './search_service_client'; -export {UserEventServiceClient} from './user_event_service_client'; diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client.ts deleted file mode 100644 index 1975118bf9f..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client.ts +++ /dev/null @@ -1,937 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/recommendation_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './recommendation_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for making recommendations. - * @class - * @memberof v1beta - */ -export class RecommendationServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - recommendationServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RecommendationServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new RecommendationServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof RecommendationServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationCollectionDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}' - ), - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1beta.RecommendationService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.recommendationServiceStub) { - return this.recommendationServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1beta.RecommendationService. - this.recommendationServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.RecommendationService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1beta.RecommendationService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const recommendationServiceStubMethods = - ['recommend']; - for (const methodName of recommendationServiceStubMethods) { - const callPromise = this.recommendationServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.recommendationServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Makes a recommendation, which requires a contextual user event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. Full resource name of the format: - * `projects/* /locations/global/collections/* /dataStores/* /servingConfigs/*` - * - * Before you can request recommendations from your model, you must create at - * least one serving config for it. - * @param {google.cloud.discoveryengine.v1beta.UserEvent} request.userEvent - * Required. Context about the user, what they are looking at and what action - * they took to trigger the Recommend 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 - * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} - * or - * {@link google.cloud.discoveryengine.v1beta.UserInfo.user_id|UserEvent.user_info.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 - * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} - * to a random unique ID and leave - * {@link google.cloud.discoveryengine.v1beta.UserInfo.user_id|UserEvent.user_info.user_id} - * unset. - * @param {number} request.pageSize - * Maximum number of results to return. Set this property - * to the number of recommendation 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. - * @param {string} request.filter - * Filter for restricting recommendation results with a length limit of 5,000 - * characters. Currently, only filter expressions on the `filter_tags` - * attribute is supported. - * - * - * Examples: - * - * * `(filter_tags: ANY("Red", "Blue") OR filter_tags: ANY("Hot", "Cold"))` - * * `(filter_tags: ANY("Red", "Blue")) AND NOT (filter_tags: ANY("Green"))` - * - * If your filter blocks all results, the API will return generic - * (unfiltered) popular Documents. If you only want results strictly matching - * the filters, set `strictFiltering` to True in - * {@link google.cloud.discoveryengine.v1beta.RecommendRequest.params|RecommendRequest.params} - * to receive empty results instead. - * - * Note that the API will never return - * {@link google.cloud.discoveryengine.v1beta.Document|Document}s with - * `storageStatus` of `EXPIRED` or `DELETED` regardless of filter choices. - * @param {boolean} request.validateOnly - * Use validate only mode for this recommendation query. If set to true, a - * fake model will be used that returns arbitrary Document IDs. - * Note that the validate only mode should only be used for testing the API, - * or if the model is not ready. - * @param {number[]} request.params - * Additional domain specific parameters for the recommendations. - * - * Allowed values: - * - * * `returnDocument`: Boolean. If set to true, the associated Document - * object will be returned in - * {@link google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.document|RecommendResponse.RecommendationResult.document}. - * * `returnScore`: Boolean. If set to true, the recommendation 'score' - * corresponding to each returned Document will be set in - * {@link google.cloud.discoveryengine.v1beta.RecommendResponse.RecommendationResult.metadata|RecommendResponse.RecommendationResult.metadata}. - * The given 'score' indicates the probability of a Document conversion - * given the user's context and history. - * * `strictFiltering`: Boolean. True by default. If set to false, the service - * will return generic (unfiltered) popular Documents instead of empty if - * your filter blocks all recommendation results. - * * `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 recommendation results - * based on Document category. - * @param {number[]} request.userLabels - * The user 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 [Requirements for - * labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) - * for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.RecommendResponse | RecommendResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta/recommendation_service.recommend.js - * region_tag:discoveryengine_v1beta_generated_RecommendationService_Recommend_async - */ - recommend( - request?: protos.google.cloud.discoveryengine.v1beta.IRecommendRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, - protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|undefined, {}|undefined - ]>; - recommend( - request: protos.google.cloud.discoveryengine.v1beta.IRecommendRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, - protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|null|undefined, - {}|null|undefined>): void; - recommend( - request: protos.google.cloud.discoveryengine.v1beta.IRecommendRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, - protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|null|undefined, - {}|null|undefined>): void; - recommend( - request?: protos.google.cloud.discoveryengine.v1beta.IRecommendRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, - protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, - protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IRecommendResponse, - protos.google.cloud.discoveryengine.v1beta.IRecommendRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'serving_config': request.servingConfig ?? '', - }); - this.initialize(); - return this.innerApiCalls.recommend(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreServingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} serving_config - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreServingConfigPath(project:string,location:string,collection:string,dataStore:string,servingConfig:string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).data_store; - } - - /** - * Parse the serving_config from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).serving_config; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStoreServingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} serving_config - * @returns {string} Resource name string. - */ - projectLocationDataStoreServingConfigPath(project:string,location:string,dataStore:string,servingConfig:string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).data_store; - } - - /** - * Parse the serving_config from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.recommendationServiceStub && !this._terminated) { - return this.recommendationServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client_config.json deleted file mode 100644 index ceaf901f32b..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_client_config.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1beta.RecommendationService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Recommend": { - "timeout_millis": 5000, - "retry_codes_name": "unavailable", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_proto_list.json deleted file mode 100644 index c90e69baf40..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/recommendation_service_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1beta/common.proto", - "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client.ts deleted file mode 100644 index 17490984ed2..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client.ts +++ /dev/null @@ -1,1553 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/schema_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './schema_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for managing {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s. - * @class - * @memberof v1beta - */ -export class SchemaServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - schemaServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SchemaServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new SchemaServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SchemaServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' - ), - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listSchemas: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'schemas') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{get: '/v1beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*}/operations',},{get: '/v1beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createSchemaResponse = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.Schema') as gax.protobuf.Type; - const createSchemaMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.CreateSchemaMetadata') as gax.protobuf.Type; - const updateSchemaResponse = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.Schema') as gax.protobuf.Type; - const updateSchemaMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.UpdateSchemaMetadata') as gax.protobuf.Type; - const deleteSchemaResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteSchemaMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.DeleteSchemaMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createSchema: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createSchemaResponse.decode.bind(createSchemaResponse), - createSchemaMetadata.decode.bind(createSchemaMetadata)), - updateSchema: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateSchemaResponse.decode.bind(updateSchemaResponse), - updateSchemaMetadata.decode.bind(updateSchemaMetadata)), - deleteSchema: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteSchemaResponse.decode.bind(deleteSchemaResponse), - deleteSchemaMetadata.decode.bind(deleteSchemaMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1beta.SchemaService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.schemaServiceStub) { - return this.schemaServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1beta.SchemaService. - this.schemaServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.SchemaService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1beta.SchemaService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const schemaServiceStubMethods = - ['getSchema', 'listSchemas', 'createSchema', 'updateSchema', 'deleteSchema']; - for (const methodName of schemaServiceStubMethods) { - const callPromise = this.schemaServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.schemaServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets a {@link google.cloud.discoveryengine.v1beta.Schema|Schema}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full resource name of the schema, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.Schema | Schema}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta/schema_service.get_schema.js - * region_tag:discoveryengine_v1beta_generated_SchemaService_GetSchema_async - */ - getSchema( - request?: protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.ISchema, - protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|undefined, {}|undefined - ]>; - getSchema( - request: protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.ISchema, - protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|null|undefined, - {}|null|undefined>): void; - getSchema( - request: protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.ISchema, - protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|null|undefined, - {}|null|undefined>): void; - getSchema( - request?: protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1beta.ISchema, - protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1beta.ISchema, - protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.ISchema, - protos.google.cloud.discoveryengine.v1beta.IGetSchemaRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getSchema(request, options, callback); - } - -/** - * Creates a {@link google.cloud.discoveryengine.v1beta.Schema|Schema}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {google.cloud.discoveryengine.v1beta.Schema} request.schema - * Required. The {@link google.cloud.discoveryengine.v1beta.Schema|Schema} to - * create. - * @param {string} request.schemaId - * Required. The ID to use for the - * {@link google.cloud.discoveryengine.v1beta.Schema|Schema}, which will become the - * final component of the - * {@link google.cloud.discoveryengine.v1beta.Schema.name|Schema.name}. - * - * This field should conform to - * [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length - * limit of 63 characters. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/schema_service.create_schema.js - * region_tag:discoveryengine_v1beta_generated_SchemaService_CreateSchema_async - */ - createSchema( - request?: protos.google.cloud.discoveryengine.v1beta.ICreateSchemaRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createSchema( - request: protos.google.cloud.discoveryengine.v1beta.ICreateSchemaRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createSchema( - request: protos.google.cloud.discoveryengine.v1beta.ICreateSchemaRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createSchema( - request?: protos.google.cloud.discoveryengine.v1beta.ICreateSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createSchema(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createSchema()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/schema_service.create_schema.js - * region_tag:discoveryengine_v1beta_generated_SchemaService_CreateSchema_async - */ - async checkCreateSchemaProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createSchema, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a {@link google.cloud.discoveryengine.v1beta.Schema|Schema}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.discoveryengine.v1beta.Schema} request.schema - * Required. The {@link google.cloud.discoveryengine.v1beta.Schema|Schema} to - * update. - * @param {boolean} request.allowMissing - * If set to true, and the - * {@link google.cloud.discoveryengine.v1beta.Schema|Schema} is not found, a new - * {@link google.cloud.discoveryengine.v1beta.Schema|Schema} will be created. In - * this situation, `update_mask` is ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/schema_service.update_schema.js - * region_tag:discoveryengine_v1beta_generated_SchemaService_UpdateSchema_async - */ - updateSchema( - request?: protos.google.cloud.discoveryengine.v1beta.IUpdateSchemaRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateSchema( - request: protos.google.cloud.discoveryengine.v1beta.IUpdateSchemaRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateSchema( - request: protos.google.cloud.discoveryengine.v1beta.IUpdateSchemaRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateSchema( - request?: protos.google.cloud.discoveryengine.v1beta.IUpdateSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'schema.name': request.schema!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateSchema(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateSchema()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/schema_service.update_schema.js - * region_tag:discoveryengine_v1beta_generated_SchemaService_UpdateSchema_async - */ - async checkUpdateSchemaProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateSchema, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a {@link google.cloud.discoveryengine.v1beta.Schema|Schema}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full resource name of the schema, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/schema_service.delete_schema.js - * region_tag:discoveryengine_v1beta_generated_SchemaService_DeleteSchema_async - */ - deleteSchema( - request?: protos.google.cloud.discoveryengine.v1beta.IDeleteSchemaRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteSchema( - request: protos.google.cloud.discoveryengine.v1beta.IDeleteSchemaRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteSchema( - request: protos.google.cloud.discoveryengine.v1beta.IDeleteSchemaRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteSchema( - request?: protos.google.cloud.discoveryengine.v1beta.IDeleteSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteSchema(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteSchema()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/schema_service.delete_schema.js - * region_tag:discoveryengine_v1beta_generated_SchemaService_DeleteSchema_async - */ - async checkDeleteSchemaProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteSchema, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Gets a list of {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {number} request.pageSize - * The maximum number of {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s - * to return. The service may return fewer than this value. - * - * If unspecified, at most 100 - * {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s will be returned. - * - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} - * must match the call that provided the page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link google.cloud.discoveryengine.v1beta.Schema | Schema}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSchemasAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listSchemas( - request?: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.ISchema[], - protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest|null, - protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse - ]>; - listSchemas( - request: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, - protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.ISchema>): void; - listSchemas( - request: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, - protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.ISchema>): void; - listSchemas( - request?: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, - protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.ISchema>, - callback?: PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, - protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.ISchema>): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.ISchema[], - protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest|null, - protos.google.cloud.discoveryengine.v1beta.IListSchemasResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listSchemas(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {number} request.pageSize - * The maximum number of {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s - * to return. The service may return fewer than this value. - * - * If unspecified, at most 100 - * {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s will be returned. - * - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} - * must match the call that provided the page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1beta.Schema | Schema} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSchemasAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listSchemasStream( - request?: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listSchemas']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSchemas.createStream( - this.innerApiCalls.listSchemas as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listSchemas`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent data store resource name, in the format of - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {number} request.pageSize - * The maximum number of {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s - * to return. The service may return fewer than this value. - * - * If unspecified, at most 100 - * {@link google.cloud.discoveryengine.v1beta.Schema|Schema}s will be returned. - * - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1beta.SchemaService.ListSchemas|SchemaService.ListSchemas} - * must match the call that provided the page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.discoveryengine.v1beta.Schema | Schema}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1beta/schema_service.list_schemas.js - * region_tag:discoveryengine_v1beta_generated_SchemaService_ListSchemas_async - */ - listSchemasAsync( - request?: protos.google.cloud.discoveryengine.v1beta.IListSchemasRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listSchemas']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSchemas.asyncIterate( - this.innerApiCalls['listSchemas'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationDataStorePath(project:string,location:string,dataStore:string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.schemaServiceStub && !this._terminated) { - return this.schemaServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client_config.json deleted file mode 100644 index 2c22818266f..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_client_config.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1beta.SchemaService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "GetSchema": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ListSchemas": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "CreateSchema": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateSchema": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "DeleteSchema": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_proto_list.json deleted file mode 100644 index c90e69baf40..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/schema_service_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1beta/common.proto", - "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client.ts deleted file mode 100644 index 41f95075218..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client.ts +++ /dev/null @@ -1,1427 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/search_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './search_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for search. - * @class - * @memberof v1beta - */ -export class SearchServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - searchServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SearchServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new SearchServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof SearchServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}' - ), - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationCollectionDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}' - ), - projectLocationDataStoreBranchPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStoreServingConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - search: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'results') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1beta.SearchService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.searchServiceStub) { - return this.searchServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1beta.SearchService. - this.searchServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.SearchService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1beta.SearchService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const searchServiceStubMethods = - ['search']; - for (const methodName of searchServiceStubMethods) { - const callPromise = this.searchServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.searchServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Performs a search. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The resource name of the Search serving config, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. - * This field is used to identify the serving configuration name, set - * of models used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. - * - * Use `default_branch` as the branch ID or leave this field empty, to search - * documents under the default branch. - * @param {string} request.query - * Raw search query. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}s - * to return. If unspecified, defaults to a reasonable value. The maximum - * allowed value is 100. Values above 100 will be coerced to 100. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {string} request.pageToken - * A page token received from a previous - * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.discoveryengine.v1beta.Document|Document}s deemed by the API - * as relevant) in search results. This field is only considered if - * {@link google.cloud.discoveryengine.v1beta.SearchRequest.page_token|page_token} - * is unset. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the documents being filtered. Filter - * expression is case-sensitive. - * - * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. - * @param {string} request.orderBy - * The order in which documents are returned. Document can be ordered by - * a field in an {@link google.cloud.discoveryengine.v1beta.Document|Document} - * object. Leave it unset if ordered by relevance. OrderBy expression is - * case-sensitive. - * - * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. - * @param {google.cloud.discoveryengine.v1beta.UserInfo} request.userInfo - * Information about the end user. - * Highly recommended for analytics. The user_agent string in UserInfo will - * be used to deduce device_type for analytics. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` - * error is returned. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain documents. - * @param {number[]} request.params - * Additional search parameters. - * - * For public website search only, supported values are: - * - * * `user_country_code`: string. Default empty. If set to non-empty, results - * are restricted or boosted based on the location provided. - * * `search_type`: double. Default empty. Enables non-webpage searching - * depending on the value. The only valid non-default value is 1, - * which enables image searching. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.userPseudoId - * 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. - * - * This field should NOT have a fixed value such as `unknown_visitor`. - * - * This should be the same identifier as - * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} - * and - * {@link google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec} request.contentSearchSpec - * The content search spec that configs the desired behavior of content - * search. - * @param {boolean} request.safeSearch - * Whether to turn on safe search. This is only supported for - * {@link |ContentConfig.PUBLIC_WEBSITE}. - * @param {number[]} request.userLabels - * The user 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. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult | SearchResult}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - search( - request?: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult[], - protos.google.cloud.discoveryengine.v1beta.ISearchRequest|null, - protos.google.cloud.discoveryengine.v1beta.ISearchResponse - ]>; - search( - request: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.ISearchRequest, - protos.google.cloud.discoveryengine.v1beta.ISearchResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult>): void; - search( - request: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, - callback: PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.ISearchRequest, - protos.google.cloud.discoveryengine.v1beta.ISearchResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult>): void; - search( - request?: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.ISearchRequest, - protos.google.cloud.discoveryengine.v1beta.ISearchResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult>, - callback?: PaginationCallback< - protos.google.cloud.discoveryengine.v1beta.ISearchRequest, - protos.google.cloud.discoveryengine.v1beta.ISearchResponse|null|undefined, - protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult>): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult[], - protos.google.cloud.discoveryengine.v1beta.ISearchRequest|null, - protos.google.cloud.discoveryengine.v1beta.ISearchResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'serving_config': request.servingConfig ?? '', - }); - this.initialize(); - return this.innerApiCalls.search(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The resource name of the Search serving config, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. - * This field is used to identify the serving configuration name, set - * of models used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. - * - * Use `default_branch` as the branch ID or leave this field empty, to search - * documents under the default branch. - * @param {string} request.query - * Raw search query. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}s - * to return. If unspecified, defaults to a reasonable value. The maximum - * allowed value is 100. Values above 100 will be coerced to 100. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {string} request.pageToken - * A page token received from a previous - * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.discoveryengine.v1beta.Document|Document}s deemed by the API - * as relevant) in search results. This field is only considered if - * {@link google.cloud.discoveryengine.v1beta.SearchRequest.page_token|page_token} - * is unset. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the documents being filtered. Filter - * expression is case-sensitive. - * - * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. - * @param {string} request.orderBy - * The order in which documents are returned. Document can be ordered by - * a field in an {@link google.cloud.discoveryengine.v1beta.Document|Document} - * object. Leave it unset if ordered by relevance. OrderBy expression is - * case-sensitive. - * - * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. - * @param {google.cloud.discoveryengine.v1beta.UserInfo} request.userInfo - * Information about the end user. - * Highly recommended for analytics. The user_agent string in UserInfo will - * be used to deduce device_type for analytics. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` - * error is returned. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain documents. - * @param {number[]} request.params - * Additional search parameters. - * - * For public website search only, supported values are: - * - * * `user_country_code`: string. Default empty. If set to non-empty, results - * are restricted or boosted based on the location provided. - * * `search_type`: double. Default empty. Enables non-webpage searching - * depending on the value. The only valid non-default value is 1, - * which enables image searching. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.userPseudoId - * 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. - * - * This field should NOT have a fixed value such as `unknown_visitor`. - * - * This should be the same identifier as - * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} - * and - * {@link google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec} request.contentSearchSpec - * The content search spec that configs the desired behavior of content - * search. - * @param {boolean} request.safeSearch - * Whether to turn on safe search. This is only supported for - * {@link |ContentConfig.PUBLIC_WEBSITE}. - * @param {number[]} request.userLabels - * The user 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. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult | SearchResult} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - searchStream( - request?: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'serving_config': request.servingConfig ?? '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.createStream( - this.innerApiCalls.search as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `search`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.servingConfig - * Required. The resource name of the Search serving config, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`. - * This field is used to identify the serving configuration name, set - * of models used to make the search. - * @param {string} request.branch - * The branch resource name, such as - * `projects/* /locations/global/collections/default_collection/dataStores/default_data_store/branches/0`. - * - * Use `default_branch` as the branch ID or leave this field empty, to search - * documents under the default branch. - * @param {string} request.query - * Raw search query. - * @param {number} request.pageSize - * Maximum number of {@link google.cloud.discoveryengine.v1beta.Document|Document}s - * to return. If unspecified, defaults to a reasonable value. The maximum - * allowed value is 100. Values above 100 will be coerced to 100. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {string} request.pageToken - * A page token received from a previous - * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link google.cloud.discoveryengine.v1beta.SearchService.Search|SearchService.Search} - * must match the call that provided the page token. Otherwise, an - * `INVALID_ARGUMENT` error is returned. - * @param {number} request.offset - * A 0-indexed integer that specifies the current offset (that is, starting - * result location, amongst the - * {@link google.cloud.discoveryengine.v1beta.Document|Document}s deemed by the API - * as relevant) in search results. This field is only considered if - * {@link google.cloud.discoveryengine.v1beta.SearchRequest.page_token|page_token} - * is unset. - * - * If this field is negative, an `INVALID_ARGUMENT` is returned. - * @param {string} request.filter - * The filter syntax consists of an expression language for constructing a - * predicate from one or more fields of the documents being filtered. Filter - * expression is case-sensitive. - * - * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. - * @param {string} request.orderBy - * The order in which documents are returned. Document can be ordered by - * a field in an {@link google.cloud.discoveryengine.v1beta.Document|Document} - * object. Leave it unset if ordered by relevance. OrderBy expression is - * case-sensitive. - * - * If this field is unrecognizable, an `INVALID_ARGUMENT` is returned. - * @param {google.cloud.discoveryengine.v1beta.UserInfo} request.userInfo - * Information about the end user. - * Highly recommended for analytics. The user_agent string in UserInfo will - * be used to deduce device_type for analytics. - * @param {number[]} request.facetSpecs - * Facet specifications for faceted search. If empty, no facets are returned. - * - * A maximum of 100 values are allowed. Otherwise, an `INVALID_ARGUMENT` - * error is returned. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.BoostSpec} request.boostSpec - * Boost specification to boost certain documents. - * @param {number[]} request.params - * Additional search parameters. - * - * For public website search only, supported values are: - * - * * `user_country_code`: string. Default empty. If set to non-empty, results - * are restricted or boosted based on the location provided. - * * `search_type`: double. Default empty. Enables non-webpage searching - * depending on the value. The only valid non-default value is 1, - * which enables image searching. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec - * The query expansion specification that specifies the conditions under which - * query expansion will occur. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.userPseudoId - * 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. - * - * This field should NOT have a fixed value such as `unknown_visitor`. - * - * This should be the same identifier as - * {@link google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id|UserEvent.user_pseudo_id} - * and - * {@link google.cloud.discoveryengine.v1beta.CompleteQueryRequest.user_pseudo_id|CompleteQueryRequest.user_pseudo_id} - * - * The field must be a UTF-8 encoded string with a length limit of 128 - * characters. Otherwise, an `INVALID_ARGUMENT` error is returned. - * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec} request.contentSearchSpec - * The content search spec that configs the desired behavior of content - * search. - * @param {boolean} request.safeSearch - * Whether to turn on safe search. This is only supported for - * {@link |ContentConfig.PUBLIC_WEBSITE}. - * @param {number[]} request.userLabels - * The user 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. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult | SearchResult}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1beta/search_service.search.js - * region_tag:discoveryengine_v1beta_generated_SearchService_Search_async - */ - searchAsync( - request?: protos.google.cloud.discoveryengine.v1beta.ISearchRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'serving_config': request.servingConfig ?? '', - }); - const defaultCallSettings = this._defaults['search']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.search.asyncIterate( - this.innerApiCalls['search'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchPath(project:string,location:string,collection:string,dataStore:string,branch:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranch resource. - * - * @param {string} projectLocationCollectionDataStoreBranchName - * A fully-qualified path representing project_location_collection_data_store_branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchName(projectLocationCollectionDataStoreBranchName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match(projectLocationCollectionDataStoreBranchName).branch; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreServingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} serving_config - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreServingConfigPath(project:string,location:string,collection:string,dataStore:string,servingConfig:string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).data_store; - } - - /** - * Parse the serving_config from ProjectLocationCollectionDataStoreServingConfig resource. - * - * @param {string} projectLocationCollectionDataStoreServingConfigName - * A fully-qualified path representing project_location_collection_data_store_serving_config resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(projectLocationCollectionDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match(projectLocationCollectionDataStoreServingConfigName).serving_config; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranch resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchPath(project:string,location:string,dataStore:string,branch:string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranch resource. - * - * @param {string} projectLocationDataStoreBranchName - * A fully-qualified path representing project_location_data_store_branch resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchName(projectLocationDataStoreBranchName: string) { - return this.pathTemplates.projectLocationDataStoreBranchPathTemplate.match(projectLocationDataStoreBranchName).branch; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStoreServingConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} serving_config - * @returns {string} Resource name string. - */ - projectLocationDataStoreServingConfigPath(project:string,location:string,dataStore:string,servingConfig:string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - serving_config: servingConfig, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).data_store; - } - - /** - * Parse the serving_config from ProjectLocationDataStoreServingConfig resource. - * - * @param {string} projectLocationDataStoreServingConfigName - * A fully-qualified path representing project_location_data_store_serving_config resource. - * @returns {string} A string representing the serving_config. - */ - matchServingConfigFromProjectLocationDataStoreServingConfigName(projectLocationDataStoreServingConfigName: string) { - return this.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match(projectLocationDataStoreServingConfigName).serving_config; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.searchServiceStub && !this._terminated) { - return this.searchServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client_config.json deleted file mode 100644 index 5efbd6c02f2..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_client_config.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1beta.SearchService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "319f27672a8be83550d842a373549dd84649a57e": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 5000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "Search": { - "timeout_millis": 5000, - "retry_codes_name": "unavailable", - "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_proto_list.json deleted file mode 100644 index c90e69baf40..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/search_service_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1beta/common.proto", - "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client.ts deleted file mode 100644 index 59c8780ebc4..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client.ts +++ /dev/null @@ -1,1220 +0,0 @@ -// Copyright 2023 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. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta/user_event_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './user_event_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for ingesting end user actions on a website to Discovery Engine API. - * @class - * @memberof v1beta - */ -export class UserEventServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - userEventServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of UserEventServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new UserEventServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof UserEventServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - projectLocationCollectionDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}' - ), - projectLocationCollectionDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationCollectionDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema}' - ), - projectLocationDataStorePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}' - ), - projectLocationDataStoreBranchDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document}' - ), - projectLocationDataStoreSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*/operations/*}',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/operations/*}',},{get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{get: '/v1beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/branches/*}/operations',additional_bindings: [{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*/schemas/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/collections/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/branches/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*/models/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*/dataStores/*}/operations',},{get: '/v1beta/{name=projects/*/locations/*}/operations',},{get: '/v1beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const importUserEventsResponse = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.ImportUserEventsResponse') as gax.protobuf.Type; - const importUserEventsMetadata = protoFilesRoot.lookup( - '.google.cloud.discoveryengine.v1beta.ImportUserEventsMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - importUserEvents: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importUserEventsResponse.decode.bind(importUserEventsResponse), - importUserEventsMetadata.decode.bind(importUserEventsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.discoveryengine.v1beta.UserEventService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.userEventServiceStub) { - return this.userEventServiceStub; - } - - // Put together the "service stub" for - // google.cloud.discoveryengine.v1beta.UserEventService. - this.userEventServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.discoveryengine.v1beta.UserEventService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.discoveryengine.v1beta.UserEventService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const userEventServiceStubMethods = - ['writeUserEvent', 'collectUserEvent', 'importUserEvents']; - for (const methodName of userEventServiceStubMethods) { - const callPromise = this.userEventServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.userEventServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'discoveryengine.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Writes a single user event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent DataStore resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {google.cloud.discoveryengine.v1beta.UserEvent} request.userEvent - * Required. User event to write. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.discoveryengine.v1beta.UserEvent | UserEvent}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta/user_event_service.write_user_event.js - * region_tag:discoveryengine_v1beta_generated_UserEventService_WriteUserEvent_async - */ - writeUserEvent( - request?: protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IUserEvent, - protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|undefined, {}|undefined - ]>; - writeUserEvent( - request: protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.IUserEvent, - protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request: protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest, - callback: Callback< - protos.google.cloud.discoveryengine.v1beta.IUserEvent, - protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): void; - writeUserEvent( - request?: protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.discoveryengine.v1beta.IUserEvent, - protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.discoveryengine.v1beta.IUserEvent, - protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.discoveryengine.v1beta.IUserEvent, - protos.google.cloud.discoveryengine.v1beta.IWriteUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.writeUserEvent(request, options, callback); - } -/** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a 3rd party domain. - * - * This method is used only by the Discovery Engine API JavaScript pixel and - * Google Tag Manager. Users should not call this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent DataStore resource name, such as - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`. - * @param {string} request.userEvent - * Required. URL encoded UserEvent proto with a length limit of 2,000,000 - * characters. - * @param {string} request.uri - * 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. - * @param {number} request.ets - * The event timestamp in milliseconds. This prevents browser caching of - * otherwise identical get requests. The name is abbreviated to reduce the - * payload bytes. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.api.HttpBody | HttpBody}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta/user_event_service.collect_user_event.js - * region_tag:discoveryengine_v1beta_generated_UserEventService_CollectUserEvent_async - */ - collectUserEvent( - request?: protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest, - options?: CallOptions): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|undefined, {}|undefined - ]>; - collectUserEvent( - request: protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest, - options: CallOptions, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request: protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest, - callback: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): void; - collectUserEvent( - request?: protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.api.IHttpBody, - protos.google.cloud.discoveryengine.v1beta.ICollectUserEventRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.collectUserEvent(request, options, callback); - } - -/** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.discoveryengine.v1beta.ImportUserEventsRequest.InlineSource} request.inlineSource - * The Inline source for the input content for UserEvents. - * @param {google.cloud.discoveryengine.v1beta.GcsSource} request.gcsSource - * Cloud Storage location for the input content. - * @param {google.cloud.discoveryengine.v1beta.BigQuerySource} request.bigquerySource - * BigQuery input source. - * @param {string} request.parent - * Required. Parent DataStore resource name, of the form - * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}` - * @param {google.cloud.discoveryengine.v1beta.ImportErrorConfig} request.errorConfig - * The desired location of errors incurred during the Import. Cannot be set - * for inline user event imports. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/user_event_service.import_user_events.js - * region_tag:discoveryengine_v1beta_generated_UserEventService_ImportUserEvents_async - */ - importUserEvents( - request?: protos.google.cloud.discoveryengine.v1beta.IImportUserEventsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importUserEvents( - request: protos.google.cloud.discoveryengine.v1beta.IImportUserEventsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request: protos.google.cloud.discoveryengine.v1beta.IImportUserEventsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importUserEvents( - request?: protos.google.cloud.discoveryengine.v1beta.IImportUserEventsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.importUserEvents(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importUserEvents()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta/user_event_service.import_user_events.js - * region_tag:discoveryengine_v1beta_generated_UserEventService_ImportUserEvents_async - */ - async checkImportUserEventsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importUserEvents, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified projectLocationCollectionDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStorePath(project:string,location:string,collection:string,dataStore:string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStore resource. - * - * @param {string} projectLocationCollectionDataStoreName - * A fully-qualified path representing project_location_collection_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreName(projectLocationCollectionDataStoreName: string) { - return this.pathTemplates.projectLocationCollectionDataStorePathTemplate.match(projectLocationCollectionDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreBranchDocumentPath(project:string,location:string,collection:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationCollectionDataStoreBranchDocument resource. - * - * @param {string} projectLocationCollectionDataStoreBranchDocumentName - * A fully-qualified path representing project_location_collection_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(projectLocationCollectionDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match(projectLocationCollectionDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationCollectionDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} collection - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationCollectionDataStoreSchemaPath(project:string,location:string,collection:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - collection: collection, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).location; - } - - /** - * Parse the collection from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).collection; - } - - /** - * Parse the data_store from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationCollectionDataStoreSchema resource. - * - * @param {string} projectLocationCollectionDataStoreSchemaName - * A fully-qualified path representing project_location_collection_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationCollectionDataStoreSchemaName(projectLocationCollectionDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match(projectLocationCollectionDataStoreSchemaName).schema; - } - - /** - * Return a fully-qualified projectLocationDataStore resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @returns {string} Resource name string. - */ - projectLocationDataStorePath(project:string,location:string,dataStore:string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - }); - } - - /** - * Parse the project from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).project; - } - - /** - * Parse the location from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStore resource. - * - * @param {string} projectLocationDataStoreName - * A fully-qualified path representing project_location_data_store resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreName(projectLocationDataStoreName: string) { - return this.pathTemplates.projectLocationDataStorePathTemplate.match(projectLocationDataStoreName).data_store; - } - - /** - * Return a fully-qualified projectLocationDataStoreBranchDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} branch - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDataStoreBranchDocumentPath(project:string,location:string,dataStore:string,branch:string,document:string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - branch: branch, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).data_store; - } - - /** - * Parse the branch from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the branch. - */ - matchBranchFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).branch; - } - - /** - * Parse the document from ProjectLocationDataStoreBranchDocument resource. - * - * @param {string} projectLocationDataStoreBranchDocumentName - * A fully-qualified path representing project_location_data_store_branch_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDataStoreBranchDocumentName(projectLocationDataStoreBranchDocumentName: string) { - return this.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match(projectLocationDataStoreBranchDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDataStoreSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} data_store - * @param {string} schema - * @returns {string} Resource name string. - */ - projectLocationDataStoreSchemaPath(project:string,location:string,dataStore:string,schema:string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render({ - project: project, - location: location, - data_store: dataStore, - schema: schema, - }); - } - - /** - * Parse the project from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).project; - } - - /** - * Parse the location from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).location; - } - - /** - * Parse the data_store from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the data_store. - */ - matchDataStoreFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).data_store; - } - - /** - * Parse the schema from ProjectLocationDataStoreSchema resource. - * - * @param {string} projectLocationDataStoreSchemaName - * A fully-qualified path representing project_location_data_store_schema resource. - * @returns {string} A string representing the schema. - */ - matchSchemaFromProjectLocationDataStoreSchemaName(projectLocationDataStoreSchemaName: string) { - return this.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match(projectLocationDataStoreSchemaName).schema; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.userEventServiceStub && !this._terminated) { - return this.userEventServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client_config.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client_config.json deleted file mode 100644 index 556c7486730..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_client_config.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "interfaces": { - "google.cloud.discoveryengine.v1beta.UserEventService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 30000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "WriteUserEvent": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "CollectUserEvent": { - "timeout_millis": 30000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "ImportUserEvents": { - "timeout_millis": 300000, - "retry_codes_name": "unavailable", - "retry_params_name": "e6a9f61a856ca7c2128ab9550ca4fb9e97c77876" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_proto_list.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_proto_list.json deleted file mode 100644 index c90e69baf40..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/src/v1beta/user_event_service_proto_list.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "../../protos/google/cloud/discoveryengine/v1beta/common.proto", - "../../protos/google/cloud/discoveryengine/v1beta/completion_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document.proto", - "../../protos/google/cloud/discoveryengine/v1beta/document_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/import_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/purge_config.proto", - "../../protos/google/cloud/discoveryengine/v1beta/recommendation_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema.proto", - "../../protos/google/cloud/discoveryengine/v1beta/schema_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/search_service.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event.proto", - "../../protos/google/cloud/discoveryengine/v1beta/user_event_service.proto" -] diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.js deleted file mode 100644 index d40d5fb6af2..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const discoveryengine = require('@google-cloud/discoveryengine'); - -function main() { - const completionServiceClient = new discoveryengine.CompletionServiceClient(); - const documentServiceClient = new discoveryengine.DocumentServiceClient(); - const recommendationServiceClient = new discoveryengine.RecommendationServiceClient(); - const schemaServiceClient = new discoveryengine.SchemaServiceClient(); - const searchServiceClient = new discoveryengine.SearchServiceClient(); - const userEventServiceClient = new discoveryengine.UserEventServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 88a2bd48482..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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. ** - -import {CompletionServiceClient, DocumentServiceClient, RecommendationServiceClient, SchemaServiceClient, SearchServiceClient, UserEventServiceClient} from '@google-cloud/discoveryengine'; - -// check that the client class type name can be used -function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { - client.close(); -} -function doStuffWithDocumentServiceClient(client: DocumentServiceClient) { - client.close(); -} -function doStuffWithRecommendationServiceClient(client: RecommendationServiceClient) { - client.close(); -} -function doStuffWithSchemaServiceClient(client: SchemaServiceClient) { - client.close(); -} -function doStuffWithSearchServiceClient(client: SearchServiceClient) { - client.close(); -} -function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const completionServiceClient = new CompletionServiceClient(); - doStuffWithCompletionServiceClient(completionServiceClient); - // check that the client instance can be created - const documentServiceClient = new DocumentServiceClient(); - doStuffWithDocumentServiceClient(documentServiceClient); - // check that the client instance can be created - const recommendationServiceClient = new RecommendationServiceClient(); - doStuffWithRecommendationServiceClient(recommendationServiceClient); - // check that the client instance can be created - const schemaServiceClient = new SchemaServiceClient(); - doStuffWithSchemaServiceClient(schemaServiceClient); - // check that the client instance can be created - const searchServiceClient = new SearchServiceClient(); - doStuffWithSearchServiceClient(searchServiceClient); - // check that the client instance can be created - const userEventServiceClient = new UserEventServiceClient(); - doStuffWithUserEventServiceClient(userEventServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/install.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 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. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_completion_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_completion_service_v1beta.ts deleted file mode 100644 index 38dbbafcb0e..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_completion_service_v1beta.ts +++ /dev/null @@ -1,609 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as completionserviceModule from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1beta.CompletionServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = completionserviceModule.v1beta.CompletionServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = completionserviceModule.v1beta.CompletionServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = completionserviceModule.v1beta.CompletionServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new completionserviceModule.v1beta.CompletionServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - await client.initialize(); - assert(client.completionServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.completionServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('completeQuery', () => { - it('invokes completeQuery without error', async () => { - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CompleteQueryRequest', ['dataStore']); - request.dataStore = defaultValue1; - const expectedHeaderRequestParams = `data_store=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CompleteQueryResponse() - ); - client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); - const [response] = await client.completeQuery(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes completeQuery without error using callback', async () => { - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CompleteQueryRequest', ['dataStore']); - request.dataStore = defaultValue1; - const expectedHeaderRequestParams = `data_store=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CompleteQueryResponse() - ); - client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.completeQuery( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.ICompleteQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes completeQuery with error', async () => { - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CompleteQueryRequest', ['dataStore']); - request.dataStore = defaultValue1; - const expectedHeaderRequestParams = `data_store=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes completeQuery with closed client', async () => { - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CompleteQueryRequest', ['dataStore']); - request.dataStore = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.completeQuery(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStore', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - }; - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStorePath', () => { - const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStore', () => { - const fakePath = "/rendered/path/projectLocationDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - }; - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStorePath', () => { - const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreName', () => { - const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreName', () => { - const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new completionserviceModule.v1beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_document_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_document_service_v1beta.ts deleted file mode 100644 index 6b76fc7b39c..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_document_service_v1beta.ts +++ /dev/null @@ -1,1824 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as documentserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta.DocumentServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = documentserviceModule.v1beta.DocumentServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = documentserviceModule.v1beta.DocumentServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = documentserviceModule.v1beta.DocumentServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentServiceStub, undefined); - await client.initialize(); - assert(client.documentServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.documentServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('getDocument', () => { - it('invokes getDocument without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.Document() - ); - client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); - const [response] = await client.getDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocument without error using callback', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.Document() - ); - client.innerApiCalls.getDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDocument( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocument with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocument with closed client', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDocument(request), expectedError); - }); - }); - - describe('createDocument', () => { - it('invokes createDocument without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.Document() - ); - client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); - const [response] = await client.createDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocument without error using callback', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.Document() - ); - client.innerApiCalls.createDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDocument( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocument with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocument with closed client', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createDocument(request), expectedError); - }); - }); - - describe('updateDocument', () => { - it('invokes updateDocument without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest() - ); - request.document ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.Document() - ); - client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); - const [response] = await client.updateDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocument without error using callback', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest() - ); - request.document ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.Document() - ); - client.innerApiCalls.updateDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDocument( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocument with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest() - ); - request.document ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocument with closed client', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest() - ); - request.document ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateDocument(request), expectedError); - }); - }); - - describe('deleteDocument', () => { - it('invokes deleteDocument without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocument without error using callback', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDocument( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocument with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocument with closed client', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteDocument(request), expectedError); - }); - }); - - describe('importDocuments', () => { - it('invokes importDocuments without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importDocuments = stubLongRunningCall(expectedResponse); - const [operation] = await client.importDocuments(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importDocuments without error using callback', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importDocuments = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importDocuments( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importDocuments with call error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importDocuments with LRO error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportDocumentsProgress without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportDocumentsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportDocumentsProgress with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportDocumentsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('purgeDocuments', () => { - it('invokes purgeDocuments without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeDocuments = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeDocuments(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeDocuments without error using callback', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeDocuments = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeDocuments( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeDocuments with call error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeDocuments with LRO error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkPurgeDocumentsProgress without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPurgeDocumentsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPurgeDocumentsProgress with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPurgeDocumentsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listDocuments', () => { - it('invokes listDocuments without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - ]; - client.innerApiCalls.listDocuments = stubSimpleCall(expectedResponse); - const [response] = await client.listDocuments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDocuments without error using callback', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - ]; - client.innerApiCalls.listDocuments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDocuments( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IDocument[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDocuments with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDocumentsStream without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - ]; - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDocumentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1beta.Document[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.Document) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); - assert( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listDocumentsStream with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDocumentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1beta.Document[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.Document) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); - assert( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDocuments without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Document()), - ]; - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.discoveryengine.v1beta.IDocument[] = []; - const iterable = client.listDocumentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDocuments with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDocumentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.discoveryengine.v1beta.IDocument[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStoreBranch', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - }; - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchPath', () => { - const result = client.projectLocationCollectionDataStoreBranchPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranch', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - }; - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchPath', () => { - const result = client.projectLocationDataStoreBranchPath("projectValue", "locationValue", "dataStoreValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new documentserviceModule.v1beta.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_recommendation_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_recommendation_service_v1beta.ts deleted file mode 100644 index 35a785daf1a..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_recommendation_service_v1beta.ts +++ /dev/null @@ -1,625 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as recommendationserviceModule from '../src'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1beta.RecommendationServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = recommendationserviceModule.v1beta.RecommendationServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = recommendationserviceModule.v1beta.RecommendationServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = recommendationserviceModule.v1beta.RecommendationServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recommendationServiceStub, undefined); - await client.initialize(); - assert(client.recommendationServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.recommendationServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.recommendationServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('recommend', () => { - it('invokes recommend without error', async () => { - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.RecommendRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.RecommendRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.RecommendResponse() - ); - client.innerApiCalls.recommend = stubSimpleCall(expectedResponse); - const [response] = await client.recommend(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.recommend as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.recommend as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes recommend without error using callback', async () => { - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.RecommendRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.RecommendRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.RecommendResponse() - ); - client.innerApiCalls.recommend = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.recommend( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IRecommendResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.recommend as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.recommend as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes recommend with error', async () => { - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.RecommendRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.RecommendRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.recommend = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.recommend(request), expectedError); - const actualRequest = (client.innerApiCalls.recommend as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.recommend as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes recommend with closed client', async () => { - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.RecommendRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.RecommendRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.recommend(request), expectedError); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreServingConfig', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreServingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - serving_config: "servingConfigValue", - }; - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreServingConfigPath', () => { - const result = client.projectLocationCollectionDataStoreServingConfigPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreServingConfig', () => { - const fakePath = "/rendered/path/projectLocationDataStoreServingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - serving_config: "servingConfigValue", - }; - const client = new recommendationserviceModule.v1beta.RecommendationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreServingConfigPath', () => { - const result = client.projectLocationDataStoreServingConfigPath("projectValue", "locationValue", "dataStoreValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchProjectFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchLocationFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchServingConfigFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_schema_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_schema_service_v1beta.ts deleted file mode 100644 index 35693b1a9f0..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_schema_service_v1beta.ts +++ /dev/null @@ -1,1638 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as schemaserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta.SchemaServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = schemaserviceModule.v1beta.SchemaServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = schemaserviceModule.v1beta.SchemaServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = schemaserviceModule.v1beta.SchemaServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.schemaServiceStub, undefined); - await client.initialize(); - assert(client.schemaServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.schemaServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.schemaServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('getSchema', () => { - it('invokes getSchema without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.GetSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.Schema() - ); - client.innerApiCalls.getSchema = stubSimpleCall(expectedResponse); - const [response] = await client.getSchema(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchema without error using callback', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.GetSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.Schema() - ); - client.innerApiCalls.getSchema = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSchema( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.ISchema|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchema with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.GetSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSchema = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSchema with closed client', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.GetSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.GetSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getSchema(request), expectedError); - }); - }); - - describe('createSchema', () => { - it('invokes createSchema without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CreateSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSchema = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSchema(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSchema without error using callback', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CreateSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSchema = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSchema( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSchema with call error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CreateSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSchema = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSchema with LRO error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CreateSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CreateSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSchema = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSchema(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateSchemaProgress without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateSchemaProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateSchemaProgress with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateSchemaProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateSchema', () => { - it('invokes updateSchema without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest() - ); - request.schema ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest', ['schema', 'name']); - request.schema.name = defaultValue1; - const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSchema = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateSchema(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSchema without error using callback', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest() - ); - request.schema ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest', ['schema', 'name']); - request.schema.name = defaultValue1; - const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateSchema = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSchema( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSchema with call error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest() - ); - request.schema ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest', ['schema', 'name']); - request.schema.name = defaultValue1; - const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSchema = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSchema with LRO error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest() - ); - request.schema ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.UpdateSchemaRequest', ['schema', 'name']); - request.schema.name = defaultValue1; - const expectedHeaderRequestParams = `schema.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSchema = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateSchema(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateSchemaProgress without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateSchemaProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateSchemaProgress with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateSchemaProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteSchema', () => { - it('invokes deleteSchema without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSchema = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteSchema(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSchema without error using callback', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteSchema = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSchema( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSchema with call error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSchema = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSchema with LRO error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.DeleteSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSchema = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteSchema(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteSchemaProgress without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteSchemaProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteSchemaProgress with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteSchemaProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listSchemas', () => { - it('invokes listSchemas without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - ]; - client.innerApiCalls.listSchemas = stubSimpleCall(expectedResponse); - const [response] = await client.listSchemas(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSchemas without error using callback', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - ]; - client.innerApiCalls.listSchemas = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSchemas( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.ISchema[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSchemas with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSchemas = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSchemas(request), expectedError); - const actualRequest = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSchemas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSchemasStream without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - ]; - client.descriptors.page.listSchemas.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSchemasStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1beta.Schema[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.Schema) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSchemas.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSchemas, request)); - assert( - (client.descriptors.page.listSchemas.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listSchemasStream with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSchemas.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSchemasStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1beta.Schema[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.Schema) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSchemas.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSchemas, request)); - assert( - (client.descriptors.page.listSchemas.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSchemas without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.Schema()), - ]; - client.descriptors.page.listSchemas.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.discoveryengine.v1beta.ISchema[] = []; - const iterable = client.listSchemasAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSchemas.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSchemas.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSchemas with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ListSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ListSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSchemas.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSchemasAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.discoveryengine.v1beta.ISchema[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSchemas.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSchemas.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStore', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - }; - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStorePath', () => { - const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStore', () => { - const fakePath = "/rendered/path/projectLocationDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - }; - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStorePath', () => { - const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreName', () => { - const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreName', () => { - const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new schemaserviceModule.v1beta.SchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_search_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_search_service_v1beta.ts deleted file mode 100644 index ba61eb9411d..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_search_service_v1beta.ts +++ /dev/null @@ -1,925 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as searchserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta.SearchServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = searchserviceModule.v1beta.SearchServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = searchserviceModule.v1beta.SearchServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = searchserviceModule.v1beta.SearchServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new searchserviceModule.v1beta.SearchServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - await client.initialize(); - assert(client.searchServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.searchServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.searchServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('search', () => { - it('invokes search without error', async () => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCall(expectedResponse); - const [response] = await client.search(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes search without error using callback', async () => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - ]; - client.innerApiCalls.search = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.search( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes search with error', async () => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchStream without error', async () => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes searchStream with error', async () => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.search.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult[] = []; - stream.on('data', (response: protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.search.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.search, request)); - assert( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with search without error', async () => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - generateSampleMessage(new protos.google.cloud.discoveryengine.v1beta.SearchResponse.SearchResult()), - ]; - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult[] = []; - const iterable = client.searchAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with search with error', async () => { - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.SearchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.SearchRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.search.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.discoveryengine.v1beta.SearchResponse.ISearchResult[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStoreBranch', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - }; - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchPath', () => { - const result = client.projectLocationCollectionDataStoreBranchPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreServingConfig', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreServingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - serving_config: "servingConfigValue", - }; - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreServingConfigPath', () => { - const result = client.projectLocationCollectionDataStoreServingConfigPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName', () => { - const result = client.matchServingConfigFromProjectLocationCollectionDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranch', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranch"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - }; - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchPath', () => { - const result = client.projectLocationDataStoreBranchPath("projectValue", "locationValue", "dataStoreValue", "branchValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreServingConfig', () => { - const fakePath = "/rendered/path/projectLocationDataStoreServingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - serving_config: "servingConfigValue", - }; - const client = new searchserviceModule.v1beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreServingConfigPath', () => { - const result = client.projectLocationDataStoreServingConfigPath("projectValue", "locationValue", "dataStoreValue", "servingConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchProjectFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchLocationFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServingConfigFromProjectLocationDataStoreServingConfigName', () => { - const result = client.matchServingConfigFromProjectLocationDataStoreServingConfigName(fakePath); - assert.strictEqual(result, "servingConfigValue"); - assert((client.pathTemplates.projectLocationDataStoreServingConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_user_event_service_v1beta.ts b/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_user_event_service_v1beta.ts deleted file mode 100644 index 09d4aec93b1..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/test/gapic_user_event_service_v1beta.ts +++ /dev/null @@ -1,1162 +0,0 @@ -// Copyright 2023 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. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as usereventserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta.UserEventServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = usereventserviceModule.v1beta.UserEventServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = usereventserviceModule.v1beta.UserEventServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = usereventserviceModule.v1beta.UserEventServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - await client.initialize(); - assert(client.userEventServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.userEventServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.userEventServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('writeUserEvent', () => { - it('invokes writeUserEvent without error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.WriteUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.UserEvent() - ); - client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.writeUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes writeUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.WriteUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.UserEvent() - ); - client.innerApiCalls.writeUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.writeUserEvent( - request, - (err?: Error|null, result?: protos.google.cloud.discoveryengine.v1beta.IUserEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes writeUserEvent with error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.WriteUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes writeUserEvent with closed client', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.WriteUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.writeUserEvent(request), expectedError); - }); - }); - - describe('collectUserEvent', () => { - it('invokes collectUserEvent without error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CollectUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.api.HttpBody() - ); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes collectUserEvent without error using callback', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CollectUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.api.HttpBody() - ); - client.innerApiCalls.collectUserEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.collectUserEvent( - request, - (err?: Error|null, result?: protos.google.api.IHttpBody|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes collectUserEvent with error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CollectUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes collectUserEvent with closed client', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.CollectUserEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.collectUserEvent(request), expectedError); - }); - }); - - describe('importUserEvents', () => { - it('invokes importUserEvents without error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importUserEvents = stubLongRunningCall(expectedResponse); - const [operation] = await client.importUserEvents(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importUserEvents without error using callback', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importUserEvents = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importUserEvents( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importUserEvents with call error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importUserEvents with LRO error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.discoveryengine.v1beta.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkImportUserEventsProgress without error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportUserEventsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportUserEventsProgress with error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportUserEventsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('projectLocationCollectionDataStore', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - }; - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStorePath', () => { - const result = client.projectLocationCollectionDataStorePath("projectValue", "locationValue", "collectionValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreBranchDocumentPath', () => { - const result = client.projectLocationCollectionDataStoreBranchDocumentPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationCollectionDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationCollectionDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationCollectionDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - collection: "collectionValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationCollectionDataStoreSchemaPath', () => { - const result = client.projectLocationCollectionDataStoreSchemaPath("projectValue", "locationValue", "collectionValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchCollectionFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationCollectionDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationCollectionDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationCollectionDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStore', () => { - const fakePath = "/rendered/path/projectLocationDataStore"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - }; - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStorePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStorePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStorePath', () => { - const result = client.projectLocationDataStorePath("projectValue", "locationValue", "dataStoreValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreName', () => { - const result = client.matchProjectFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreName', () => { - const result = client.matchLocationFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStorePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreBranchDocument', () => { - const fakePath = "/rendered/path/projectLocationDataStoreBranchDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - branch: "branchValue", - document: "documentValue", - }; - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreBranchDocumentPath', () => { - const result = client.projectLocationDataStoreBranchDocumentPath("projectValue", "locationValue", "dataStoreValue", "branchValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchProjectFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchLocationFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBranchFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchBranchFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "branchValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDataStoreBranchDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDataStoreBranchDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDataStoreBranchDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDataStoreSchema', () => { - const fakePath = "/rendered/path/projectLocationDataStoreSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - data_store: "dataStoreValue", - schema: "schemaValue", - }; - const client = new usereventserviceModule.v1beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDataStoreSchemaPath', () => { - const result = client.projectLocationDataStoreSchemaPath("projectValue", "locationValue", "dataStoreValue", "schemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchProjectFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchLocationFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDataStoreFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchDataStoreFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "dataStoreValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSchemaFromProjectLocationDataStoreSchemaName', () => { - const result = client.matchSchemaFromProjectLocationDataStoreSchemaName(fakePath); - assert.strictEqual(result, "schemaValue"); - assert((client.pathTemplates.projectLocationDataStoreSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/tsconfig.json b/owl-bot-staging/google-cloud-discoveryengine/v1beta/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-discoveryengine/v1beta/webpack.config.js b/owl-bot-staging/google-cloud-discoveryengine/v1beta/webpack.config.js deleted file mode 100644 index eb56fa1d866..00000000000 --- a/owl-bot-staging/google-cloud-discoveryengine/v1beta/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 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. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'CompletionService', - filename: './completion-service.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/completion_service.proto b/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/completion_service.proto index 5a8ecd29acc..cd003bd1fa2 100644 --- a/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/completion_service.proto +++ b/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/completion_service.proto @@ -74,6 +74,8 @@ message CompleteQueryRequest { // API calls. Do not use it when there is no traffic for Search API. // * `user-event` - Using suggestions generated from user-imported search // events. + // * `document-completable` - Using suggestions taken directly from + // user-imported document fields marked as completable. // // Default values: // diff --git a/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/document.proto b/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/document.proto index 67e178c508f..677228d9011 100644 --- a/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/document.proto +++ b/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/document.proto @@ -59,8 +59,11 @@ message Document { // The MIME type of the content. Supported types: // - // * `application/pdf` (PDF) + // * `application/pdf` (PDF, only native PDFs are supported for now) // * `text/html` (HTML) + // * `application/vnd.openxmlformats-officedocument.wordprocessingml.document` (DOCX) + // * `application/vnd.openxmlformats-officedocument.presentationml.presentation` (PPTX) + // * `text/plain` (TXT) // // See https://www.iana.org/assignments/media-types/media-types.xhtml. string mime_type = 1; diff --git a/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/import_config.proto b/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/import_config.proto index 9a901c90b8e..9c68d47a0fe 100644 --- a/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/import_config.proto +++ b/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/import_config.proto @@ -60,6 +60,10 @@ message GcsSource { // * `custom`: One custom data JSON per row in arbitrary format that conforms // the defined [Schema][google.cloud.discoveryengine.v1beta.Schema] of the // data store. This can only be used by the GENERIC Data Store vertical. + // * `csv`: A CSV file with header conforming the defined + // [Schema][google.cloud.discoveryengine.v1beta.Schema] of the + // data store. Each entry after the header will be imported as a Document. + // This can only be used by the GENERIC Data Store vertical. // // Supported values for user even imports: // @@ -137,16 +141,16 @@ message ImportUserEventsRequest { repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; } - // The desired input source of the user event data. + // Required - The desired input source of the user event data. oneof source { - // Required. The Inline source for the input content for UserEvents. - InlineSource inline_source = 2 [(google.api.field_behavior) = REQUIRED]; + // The Inline source for the input content for UserEvents. + InlineSource inline_source = 2; - // Required. Cloud Storage location for the input content. - GcsSource gcs_source = 3 [(google.api.field_behavior) = REQUIRED]; + // Cloud Storage location for the input content. + GcsSource gcs_source = 3; - // Required. BigQuery input source. - BigQuerySource bigquery_source = 4 [(google.api.field_behavior) = REQUIRED]; + // BigQuery input source. + BigQuerySource bigquery_source = 4; } // Required. Parent DataStore resource name, of the form @@ -290,7 +294,7 @@ message ImportDocumentsRequest { // [GcsSource.data_schema][google.cloud.discoveryengine.v1beta.GcsSource.data_schema] // or // [BigQuerySource.data_schema][google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema] - // is `custom`. Otherwise, an INVALID_ARGUMENT error is thrown. + // is `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown. bool auto_generate_ids = 8; // The field in the Cloud Storage and BigQuery sources that indicates the diff --git a/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/search_service.proto b/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/search_service.proto index 393f2313a34..21c48e0734d 100644 --- a/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/search_service.proto +++ b/packages/google-cloud-discoveryengine/protos/google/cloud/discoveryengine/v1beta/search_service.proto @@ -287,6 +287,10 @@ message SearchRequest { // The specification that configs the snippet in the search results. message SnippetSpec { // Max number of snippets returned in each search result. + // + // A snippet is an infomartive summary of a content with highlighting for + // UI rendering. + // // If the matching snippets is less than the max_snippet_count, return all // of the snippets; otherwise, return the max_snippet_count. // @@ -308,6 +312,36 @@ message SearchRequest { int32 summary_result_count = 1; } + // The specification that configs the extractive content in search results. + message ExtractiveContentSpec { + // The max number of extractive answers returned in each search result. + // + // An extractive answer is a verbatim answer extracted from the original + // document, which provides precise and contextually relevant answer to + // the search query. + // + // If the number of matching answers is less than the + // extractive_answer_count, return all of the answers; otherwise, return + // the extractive_answer_count. + // + // At most 5 answers will be returned for each SearchResult. + int32 max_extractive_answer_count = 1; + + // The max number of extractive segments returned in each search result. + // + // An extractive segment is a text segment extracted from the original + // document which is relevant to the search query and in general more + // verbose than an extrative answer. The segment could then be used as + // input for LLMs to generate summaries and answers. + // + // If the number of matching segments is less than the + // max_extractive_segment_count, return all of the segments; otherwise, + // return the max_extractive_segment_count. + // + // Currently one segment will be returned for each SearchResult. + int32 max_extractive_segment_count = 2; + } + // If there is no snippet spec provided, there will be no snippet in the // search result. SnippetSpec snippet_spec = 1; @@ -315,6 +349,10 @@ message SearchRequest { // If there is no summary spec provided, there will be no summary in the // search response. SummarySpec summary_spec = 2; + + // If there is no extractive_content_spec provided, there will be no + // extractive answer in the search response. + ExtractiveContentSpec extractive_content_spec = 3; } // Required. The resource name of the Search serving config, such as @@ -549,6 +587,14 @@ message SearchResponse { // performance. string attribution_token = 4; + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search is performed, and only + // [redirect_uri][google.cloud.discoveryengine.v1beta.SearchResponse.redirect_uri] + // and + // [attribution_token][google.cloud.discoveryengine.v1beta.SearchResponse.attribution_token] + // are set in the response. + string redirect_uri = 12; + // A token that can be sent as // [SearchRequest.page_token][google.cloud.discoveryengine.v1beta.SearchRequest.page_token] // to retrieve the next page. If this field is omitted, there are no diff --git a/packages/google-cloud-discoveryengine/protos/protos.d.ts b/packages/google-cloud-discoveryengine/protos/protos.d.ts index 4c76f6c18a1..e305a6e0dc8 100644 --- a/packages/google-cloud-discoveryengine/protos/protos.d.ts +++ b/packages/google-cloud-discoveryengine/protos/protos.d.ts @@ -13407,6 +13407,9 @@ export namespace google { /** ContentSearchSpec summarySpec */ summarySpec?: (google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ISummarySpec|null); + + /** ContentSearchSpec extractiveContentSpec */ + extractiveContentSpec?: (google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec|null); } /** Represents a ContentSearchSpec. */ @@ -13424,6 +13427,9 @@ export namespace google { /** ContentSearchSpec summarySpec. */ public summarySpec?: (google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ISummarySpec|null); + /** ContentSearchSpec extractiveContentSpec. */ + public extractiveContentSpec?: (google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec|null); + /** * Creates a new ContentSearchSpec instance using the specified properties. * @param [properties] Properties to set @@ -13703,6 +13709,109 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of an ExtractiveContentSpec. */ + interface IExtractiveContentSpec { + + /** ExtractiveContentSpec maxExtractiveAnswerCount */ + maxExtractiveAnswerCount?: (number|null); + + /** ExtractiveContentSpec maxExtractiveSegmentCount */ + maxExtractiveSegmentCount?: (number|null); + } + + /** Represents an ExtractiveContentSpec. */ + class ExtractiveContentSpec implements IExtractiveContentSpec { + + /** + * Constructs a new ExtractiveContentSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec); + + /** ExtractiveContentSpec maxExtractiveAnswerCount. */ + public maxExtractiveAnswerCount: number; + + /** ExtractiveContentSpec maxExtractiveSegmentCount. */ + public maxExtractiveSegmentCount: number; + + /** + * Creates a new ExtractiveContentSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns ExtractiveContentSpec instance + */ + public static create(properties?: google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec): google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec; + + /** + * Encodes the specified ExtractiveContentSpec message. Does not implicitly {@link google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec.verify|verify} messages. + * @param message ExtractiveContentSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExtractiveContentSpec message, length delimited. Does not implicitly {@link google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec.verify|verify} messages. + * @param message ExtractiveContentSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExtractiveContentSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExtractiveContentSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec; + + /** + * Decodes an ExtractiveContentSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExtractiveContentSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec; + + /** + * Verifies an ExtractiveContentSpec message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExtractiveContentSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExtractiveContentSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec; + + /** + * Creates a plain object from an ExtractiveContentSpec message. Also converts values to other types if specified. + * @param message ExtractiveContentSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExtractiveContentSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExtractiveContentSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } } @@ -13724,6 +13833,9 @@ export namespace google { /** SearchResponse attributionToken */ attributionToken?: (string|null); + /** SearchResponse redirectUri */ + redirectUri?: (string|null); + /** SearchResponse nextPageToken */ nextPageToken?: (string|null); @@ -13761,6 +13873,9 @@ export namespace google { /** SearchResponse attributionToken. */ public attributionToken: string; + /** SearchResponse redirectUri. */ + public redirectUri: string; + /** SearchResponse nextPageToken. */ public nextPageToken: string; diff --git a/packages/google-cloud-discoveryengine/protos/protos.js b/packages/google-cloud-discoveryengine/protos/protos.js index ef84e523ed4..9e0a5d2f300 100644 --- a/packages/google-cloud-discoveryengine/protos/protos.js +++ b/packages/google-cloud-discoveryengine/protos/protos.js @@ -32858,6 +32858,7 @@ * @interface IContentSearchSpec * @property {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ISnippetSpec|null} [snippetSpec] ContentSearchSpec snippetSpec * @property {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ISummarySpec|null} [summarySpec] ContentSearchSpec summarySpec + * @property {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec|null} [extractiveContentSpec] ContentSearchSpec extractiveContentSpec */ /** @@ -32891,6 +32892,14 @@ */ ContentSearchSpec.prototype.summarySpec = null; + /** + * ContentSearchSpec extractiveContentSpec. + * @member {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec|null|undefined} extractiveContentSpec + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec + * @instance + */ + ContentSearchSpec.prototype.extractiveContentSpec = null; + /** * Creates a new ContentSearchSpec instance using the specified properties. * @function create @@ -32919,6 +32928,8 @@ $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SnippetSpec.encode(message.snippetSpec, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.summarySpec != null && Object.hasOwnProperty.call(message, "summarySpec")) $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SummarySpec.encode(message.summarySpec, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.extractiveContentSpec != null && Object.hasOwnProperty.call(message, "extractiveContentSpec")) + $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec.encode(message.extractiveContentSpec, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -32961,6 +32972,10 @@ message.summarySpec = $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SummarySpec.decode(reader, reader.uint32()); break; } + case 3: { + message.extractiveContentSpec = $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -33006,6 +33021,11 @@ if (error) return "summarySpec." + error; } + if (message.extractiveContentSpec != null && message.hasOwnProperty("extractiveContentSpec")) { + var error = $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec.verify(message.extractiveContentSpec); + if (error) + return "extractiveContentSpec." + error; + } return null; }; @@ -33031,6 +33051,11 @@ throw TypeError(".google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.summarySpec: object expected"); message.summarySpec = $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SummarySpec.fromObject(object.summarySpec); } + if (object.extractiveContentSpec != null) { + if (typeof object.extractiveContentSpec !== "object") + throw TypeError(".google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.extractiveContentSpec: object expected"); + message.extractiveContentSpec = $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec.fromObject(object.extractiveContentSpec); + } return message; }; @@ -33050,11 +33075,14 @@ if (options.defaults) { object.snippetSpec = null; object.summarySpec = null; + object.extractiveContentSpec = null; } if (message.snippetSpec != null && message.hasOwnProperty("snippetSpec")) object.snippetSpec = $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SnippetSpec.toObject(message.snippetSpec, options); if (message.summarySpec != null && message.hasOwnProperty("summarySpec")) object.summarySpec = $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.SummarySpec.toObject(message.summarySpec, options); + if (message.extractiveContentSpec != null && message.hasOwnProperty("extractiveContentSpec")) + object.extractiveContentSpec = $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec.toObject(message.extractiveContentSpec, options); return object; }; @@ -33514,6 +33542,233 @@ return SummarySpec; })(); + ContentSearchSpec.ExtractiveContentSpec = (function() { + + /** + * Properties of an ExtractiveContentSpec. + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec + * @interface IExtractiveContentSpec + * @property {number|null} [maxExtractiveAnswerCount] ExtractiveContentSpec maxExtractiveAnswerCount + * @property {number|null} [maxExtractiveSegmentCount] ExtractiveContentSpec maxExtractiveSegmentCount + */ + + /** + * Constructs a new ExtractiveContentSpec. + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec + * @classdesc Represents an ExtractiveContentSpec. + * @implements IExtractiveContentSpec + * @constructor + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec=} [properties] Properties to set + */ + function ExtractiveContentSpec(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExtractiveContentSpec maxExtractiveAnswerCount. + * @member {number} maxExtractiveAnswerCount + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @instance + */ + ExtractiveContentSpec.prototype.maxExtractiveAnswerCount = 0; + + /** + * ExtractiveContentSpec maxExtractiveSegmentCount. + * @member {number} maxExtractiveSegmentCount + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @instance + */ + ExtractiveContentSpec.prototype.maxExtractiveSegmentCount = 0; + + /** + * Creates a new ExtractiveContentSpec instance using the specified properties. + * @function create + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @static + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec=} [properties] Properties to set + * @returns {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec} ExtractiveContentSpec instance + */ + ExtractiveContentSpec.create = function create(properties) { + return new ExtractiveContentSpec(properties); + }; + + /** + * Encodes the specified ExtractiveContentSpec message. Does not implicitly {@link google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @static + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec} message ExtractiveContentSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtractiveContentSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.maxExtractiveAnswerCount != null && Object.hasOwnProperty.call(message, "maxExtractiveAnswerCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.maxExtractiveAnswerCount); + if (message.maxExtractiveSegmentCount != null && Object.hasOwnProperty.call(message, "maxExtractiveSegmentCount")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.maxExtractiveSegmentCount); + return writer; + }; + + /** + * Encodes the specified ExtractiveContentSpec message, length delimited. Does not implicitly {@link google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @static + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.IExtractiveContentSpec} message ExtractiveContentSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtractiveContentSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExtractiveContentSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec} ExtractiveContentSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtractiveContentSpec.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.maxExtractiveAnswerCount = reader.int32(); + break; + } + case 2: { + message.maxExtractiveSegmentCount = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExtractiveContentSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec} ExtractiveContentSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtractiveContentSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExtractiveContentSpec message. + * @function verify + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExtractiveContentSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.maxExtractiveAnswerCount != null && message.hasOwnProperty("maxExtractiveAnswerCount")) + if (!$util.isInteger(message.maxExtractiveAnswerCount)) + return "maxExtractiveAnswerCount: integer expected"; + if (message.maxExtractiveSegmentCount != null && message.hasOwnProperty("maxExtractiveSegmentCount")) + if (!$util.isInteger(message.maxExtractiveSegmentCount)) + return "maxExtractiveSegmentCount: integer expected"; + return null; + }; + + /** + * Creates an ExtractiveContentSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec} ExtractiveContentSpec + */ + ExtractiveContentSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec) + return object; + var message = new $root.google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec(); + if (object.maxExtractiveAnswerCount != null) + message.maxExtractiveAnswerCount = object.maxExtractiveAnswerCount | 0; + if (object.maxExtractiveSegmentCount != null) + message.maxExtractiveSegmentCount = object.maxExtractiveSegmentCount | 0; + return message; + }; + + /** + * Creates a plain object from an ExtractiveContentSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @static + * @param {google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec} message ExtractiveContentSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtractiveContentSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.maxExtractiveAnswerCount = 0; + object.maxExtractiveSegmentCount = 0; + } + if (message.maxExtractiveAnswerCount != null && message.hasOwnProperty("maxExtractiveAnswerCount")) + object.maxExtractiveAnswerCount = message.maxExtractiveAnswerCount; + if (message.maxExtractiveSegmentCount != null && message.hasOwnProperty("maxExtractiveSegmentCount")) + object.maxExtractiveSegmentCount = message.maxExtractiveSegmentCount; + return object; + }; + + /** + * Converts this ExtractiveContentSpec to JSON. + * @function toJSON + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @instance + * @returns {Object.} JSON object + */ + ExtractiveContentSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExtractiveContentSpec + * @function getTypeUrl + * @memberof google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExtractiveContentSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.discoveryengine.v1beta.SearchRequest.ContentSearchSpec.ExtractiveContentSpec"; + }; + + return ExtractiveContentSpec; + })(); + return ContentSearchSpec; })(); @@ -33531,6 +33786,7 @@ * @property {google.cloud.discoveryengine.v1beta.SearchResponse.IGuidedSearchResult|null} [guidedSearchResult] SearchResponse guidedSearchResult * @property {number|null} [totalSize] SearchResponse totalSize * @property {string|null} [attributionToken] SearchResponse attributionToken + * @property {string|null} [redirectUri] SearchResponse redirectUri * @property {string|null} [nextPageToken] SearchResponse nextPageToken * @property {string|null} [correctedQuery] SearchResponse correctedQuery * @property {google.cloud.discoveryengine.v1beta.SearchResponse.ISummary|null} [summary] SearchResponse summary @@ -33595,6 +33851,14 @@ */ SearchResponse.prototype.attributionToken = ""; + /** + * SearchResponse redirectUri. + * @member {string} redirectUri + * @memberof google.cloud.discoveryengine.v1beta.SearchResponse + * @instance + */ + SearchResponse.prototype.redirectUri = ""; + /** * SearchResponse nextPageToken. * @member {string} nextPageToken @@ -33672,6 +33936,8 @@ if (message.appliedControls != null && message.appliedControls.length) for (var i = 0; i < message.appliedControls.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.appliedControls[i]); + if (message.redirectUri != null && Object.hasOwnProperty.call(message, "redirectUri")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.redirectUri); return writer; }; @@ -33730,6 +33996,10 @@ message.attributionToken = reader.string(); break; } + case 12: { + message.redirectUri = reader.string(); + break; + } case 5: { message.nextPageToken = reader.string(); break; @@ -33812,6 +34082,9 @@ if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) if (!$util.isString(message.attributionToken)) return "attributionToken: string expected"; + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + if (!$util.isString(message.redirectUri)) + return "redirectUri: string expected"; if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) if (!$util.isString(message.nextPageToken)) return "nextPageToken: string expected"; @@ -33874,6 +34147,8 @@ message.totalSize = object.totalSize | 0; if (object.attributionToken != null) message.attributionToken = String(object.attributionToken); + if (object.redirectUri != null) + message.redirectUri = String(object.redirectUri); if (object.nextPageToken != null) message.nextPageToken = String(object.nextPageToken); if (object.correctedQuery != null) @@ -33918,6 +34193,7 @@ object.correctedQuery = ""; object.guidedSearchResult = null; object.summary = null; + object.redirectUri = ""; } if (message.results && message.results.length) { object.results = []; @@ -33946,6 +34222,8 @@ for (var j = 0; j < message.appliedControls.length; ++j) object.appliedControls[j] = message.appliedControls[j]; } + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + object.redirectUri = message.redirectUri; return object; }; diff --git a/packages/google-cloud-discoveryengine/protos/protos.json b/packages/google-cloud-discoveryengine/protos/protos.json index cee19da20d9..ccca6f48448 100644 --- a/packages/google-cloud-discoveryengine/protos/protos.json +++ b/packages/google-cloud-discoveryengine/protos/protos.json @@ -2386,24 +2386,15 @@ "fields": { "inlineSource": { "type": "InlineSource", - "id": 2, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } + "id": 2 }, "gcsSource": { "type": "GcsSource", - "id": 3, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } + "id": 3 }, "bigquerySource": { "type": "BigQuerySource", - "id": 4, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } + "id": 4 }, "parent": { "type": "string", @@ -3623,6 +3614,10 @@ "summarySpec": { "type": "SummarySpec", "id": 2 + }, + "extractiveContentSpec": { + "type": "ExtractiveContentSpec", + "id": 3 } }, "nested": { @@ -3645,6 +3640,18 @@ "id": 1 } } + }, + "ExtractiveContentSpec": { + "fields": { + "maxExtractiveAnswerCount": { + "type": "int32", + "id": 1 + }, + "maxExtractiveSegmentCount": { + "type": "int32", + "id": 2 + } + } } } } @@ -3674,6 +3681,10 @@ "type": "string", "id": 4 }, + "redirectUri": { + "type": "string", + "id": 12 + }, "nextPageToken": { "type": "string", "id": 5 diff --git a/packages/google-cloud-discoveryengine/samples/generated/v1beta/completion_service.complete_query.js b/packages/google-cloud-discoveryengine/samples/generated/v1beta/completion_service.complete_query.js index 995d079ea2f..9100d412b8a 100644 --- a/packages/google-cloud-discoveryengine/samples/generated/v1beta/completion_service.complete_query.js +++ b/packages/google-cloud-discoveryengine/samples/generated/v1beta/completion_service.complete_query.js @@ -48,6 +48,8 @@ function main(dataStore, query) { * API calls. Do not use it when there is no traffic for Search API. * * `user-event` - Using suggestions generated from user-imported search * events. + * * `document-completable` - Using suggestions taken directly from + * user-imported document fields marked as completable. * Default values: * * `document` is the default model for regular dataStores. * * `search-history` is the default model for diff --git a/packages/google-cloud-discoveryengine/samples/generated/v1beta/document_service.import_documents.js b/packages/google-cloud-discoveryengine/samples/generated/v1beta/document_service.import_documents.js index 129eba4de80..d737f12f8d3 100644 --- a/packages/google-cloud-discoveryengine/samples/generated/v1beta/document_service.import_documents.js +++ b/packages/google-cloud-discoveryengine/samples/generated/v1beta/document_service.import_documents.js @@ -75,7 +75,7 @@ function main(parent) { * GcsSource.data_schema google.cloud.discoveryengine.v1beta.GcsSource.data_schema * or * BigQuerySource.data_schema google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema - * is `custom`. Otherwise, an INVALID_ARGUMENT error is thrown. + * is `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown. */ // const autoGenerateIds = true /** diff --git a/packages/google-cloud-discoveryengine/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json b/packages/google-cloud-discoveryengine/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json index eaaf985c074..8761c9f24cb 100644 --- a/packages/google-cloud-discoveryengine/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json +++ b/packages/google-cloud-discoveryengine/samples/generated/v1beta/snippet_metadata.google.cloud.discoveryengine.v1beta.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 91, + "end": 93, "type": "FULL" } ], @@ -898,7 +898,7 @@ "segments": [ { "start": 25, - "end": 75, + "end": 72, "type": "FULL" } ], diff --git a/packages/google-cloud-discoveryengine/samples/generated/v1beta/user_event_service.import_user_events.js b/packages/google-cloud-discoveryengine/samples/generated/v1beta/user_event_service.import_user_events.js index 085981bc87b..536d06ef174 100644 --- a/packages/google-cloud-discoveryengine/samples/generated/v1beta/user_event_service.import_user_events.js +++ b/packages/google-cloud-discoveryengine/samples/generated/v1beta/user_event_service.import_user_events.js @@ -20,7 +20,7 @@ 'use strict'; -function main(inlineSource, gcsSource, bigquerySource, parent) { +function main(parent) { // [START discoveryengine_v1beta_generated_UserEventService_ImportUserEvents_async] /** * This snippet has been automatically generated and should be regarded as a code template only. @@ -29,15 +29,15 @@ function main(inlineSource, gcsSource, bigquerySource, parent) { * TODO(developer): Uncomment these variables before running the sample. */ /** - * Required. The Inline source for the input content for UserEvents. + * The Inline source for the input content for UserEvents. */ // const inlineSource = {} /** - * Required. Cloud Storage location for the input content. + * Cloud Storage location for the input content. */ // const gcsSource = {} /** - * Required. BigQuery input source. + * BigQuery input source. */ // const bigquerySource = {} /** @@ -60,9 +60,6 @@ function main(inlineSource, gcsSource, bigquerySource, parent) { async function callImportUserEvents() { // Construct request const request = { - inlineSource, - gcsSource, - bigquerySource, parent, }; diff --git a/packages/google-cloud-discoveryengine/src/v1beta/completion_service_client.ts b/packages/google-cloud-discoveryengine/src/v1beta/completion_service_client.ts index 433e2409707..d643e9ae9a5 100644 --- a/packages/google-cloud-discoveryengine/src/v1beta/completion_service_client.ts +++ b/packages/google-cloud-discoveryengine/src/v1beta/completion_service_client.ts @@ -356,6 +356,8 @@ export class CompletionServiceClient { * API calls. Do not use it when there is no traffic for Search API. * * `user-event` - Using suggestions generated from user-imported search * events. + * * `document-completable` - Using suggestions taken directly from + * user-imported document fields marked as completable. * * Default values: * diff --git a/packages/google-cloud-discoveryengine/src/v1beta/document_service_client.ts b/packages/google-cloud-discoveryengine/src/v1beta/document_service_client.ts index f5bf6a7e05d..754fd0ac8bd 100644 --- a/packages/google-cloud-discoveryengine/src/v1beta/document_service_client.ts +++ b/packages/google-cloud-discoveryengine/src/v1beta/document_service_client.ts @@ -955,7 +955,7 @@ export class DocumentServiceClient { * {@link google.cloud.discoveryengine.v1beta.GcsSource.data_schema|GcsSource.data_schema} * or * {@link google.cloud.discoveryengine.v1beta.BigQuerySource.data_schema|BigQuerySource.data_schema} - * is `custom`. Otherwise, an INVALID_ARGUMENT error is thrown. + * is `custom` or `csv`. Otherwise, an INVALID_ARGUMENT error is thrown. * @param {string} request.idField * The field in the Cloud Storage and BigQuery sources that indicates the * unique IDs of the documents. diff --git a/packages/google-cloud-discoveryengine/src/v1beta/user_event_service_client.ts b/packages/google-cloud-discoveryengine/src/v1beta/user_event_service_client.ts index 15040d8bce6..bafb3682d08 100644 --- a/packages/google-cloud-discoveryengine/src/v1beta/user_event_service_client.ts +++ b/packages/google-cloud-discoveryengine/src/v1beta/user_event_service_client.ts @@ -657,11 +657,11 @@ export class UserEventServiceClient { * @param {Object} request * The request object that will be sent. * @param {google.cloud.discoveryengine.v1beta.ImportUserEventsRequest.InlineSource} request.inlineSource - * Required. The Inline source for the input content for UserEvents. + * The Inline source for the input content for UserEvents. * @param {google.cloud.discoveryengine.v1beta.GcsSource} request.gcsSource - * Required. Cloud Storage location for the input content. + * Cloud Storage location for the input content. * @param {google.cloud.discoveryengine.v1beta.BigQuerySource} request.bigquerySource - * Required. BigQuery input source. + * BigQuery input source. * @param {string} request.parent * Required. Parent DataStore resource name, of the form * `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`