diff --git a/packages/google-ai-generativelanguage/README.md b/packages/google-ai-generativelanguage/README.md index a65eea4c0fb..d8acb50d893 100644 --- a/packages/google-ai-generativelanguage/README.md +++ b/packages/google-ai-generativelanguage/README.md @@ -160,6 +160,11 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/ | Generative_service.stream_generate_content | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1/generative_service.stream_generate_content.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1/generative_service.stream_generate_content.js,packages/google-ai-generativelanguage/samples/README.md) | | Model_service.get_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1/model_service.get_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1/model_service.get_model.js,packages/google-ai-generativelanguage/samples/README.md) | | Model_service.list_models | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1/model_service.list_models.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1/model_service.list_models.js,packages/google-ai-generativelanguage/samples/README.md) | +| Cache_service.create_cached_content | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.create_cached_content.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.create_cached_content.js,packages/google-ai-generativelanguage/samples/README.md) | +| Cache_service.delete_cached_content | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.delete_cached_content.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.delete_cached_content.js,packages/google-ai-generativelanguage/samples/README.md) | +| Cache_service.get_cached_content | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.get_cached_content.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.get_cached_content.js,packages/google-ai-generativelanguage/samples/README.md) | +| Cache_service.list_cached_contents | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.list_cached_contents.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.list_cached_contents.js,packages/google-ai-generativelanguage/samples/README.md) | +| Cache_service.update_cached_content | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.update_cached_content.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.update_cached_content.js,packages/google-ai-generativelanguage/samples/README.md) | | Discuss_service.count_message_tokens | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/discuss_service.count_message_tokens.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/discuss_service.count_message_tokens.js,packages/google-ai-generativelanguage/samples/README.md) | | Discuss_service.generate_message | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/discuss_service.generate_message.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/discuss_service.generate_message.js,packages/google-ai-generativelanguage/samples/README.md) | | File_service.create_file | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/file_service.create_file.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/file_service.create_file.js,packages/google-ai-generativelanguage/samples/README.md) | diff --git a/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/cache_service.proto b/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/cache_service.proto new file mode 100644 index 00000000000..b2dbe90a45e --- /dev/null +++ b/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/cache_service.proto @@ -0,0 +1,147 @@ +// Copyright 2024 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.ai.generativelanguage.v1beta; + +import "google/ai/generativelanguage/v1beta/cached_content.proto"; +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb;generativelanguagepb"; +option java_multiple_files = true; +option java_outer_classname = "CacheServiceProto"; +option java_package = "com.google.ai.generativelanguage.v1beta"; + +// API for managing cache of content (CachedContent resources) that can be used +// in GenerativeService requests. This way generate content requests can benefit +// from preprocessing work being done earlier, possibly lowering their +// computational cost. It is intended to be used with large contexts. +service CacheService { + option (google.api.default_host) = "generativelanguage.googleapis.com"; + + // Lists CachedContents. + rpc ListCachedContents(ListCachedContentsRequest) + returns (ListCachedContentsResponse) { + option (google.api.http) = { + get: "/v1beta/cachedContents" + }; + option (google.api.method_signature) = ""; + } + + // Creates CachedContent resource. + rpc CreateCachedContent(CreateCachedContentRequest) returns (CachedContent) { + option (google.api.http) = { + post: "/v1beta/cachedContents" + body: "cached_content" + }; + option (google.api.method_signature) = "cached_content"; + } + + // Reads CachedContent resource. + rpc GetCachedContent(GetCachedContentRequest) returns (CachedContent) { + option (google.api.http) = { + get: "/v1beta/{name=cachedContents/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates CachedContent resource (only expiration is updatable). + rpc UpdateCachedContent(UpdateCachedContentRequest) returns (CachedContent) { + option (google.api.http) = { + patch: "/v1beta/{cached_content.name=cachedContents/*}" + body: "cached_content" + }; + option (google.api.method_signature) = "cached_content,update_mask"; + } + + // Deletes CachedContent resource. + rpc DeleteCachedContent(DeleteCachedContentRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta/{name=cachedContents/*}" + }; + option (google.api.method_signature) = "name"; + } +} + +// Request to list CachedContents. +message ListCachedContentsRequest { + // Optional. The maximum number of cached contents to return. The service may + // return fewer than this value. If unspecified, some default (under maximum) + // number of items will be returned. The maximum value is 1000; values above + // 1000 will be coerced to 1000. + int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListCachedContents` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListCachedContents` must + // match the call that provided the page token. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response with CachedContents list. +message ListCachedContentsResponse { + // List of cached contents. + repeated CachedContent cached_contents = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Request to create CachedContent. +message CreateCachedContentRequest { + // Required. The cached content to create. + CachedContent cached_content = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request to read CachedContent. +message GetCachedContentRequest { + // Required. The resource name referring to the content cache entry. + // Format: `cachedContents/{id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "generativelanguage.googleapis.com/CachedContent" + } + ]; +} + +// Request to update CachedContent. +message UpdateCachedContentRequest { + // Required. The content cache entry to update + CachedContent cached_content = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to update. + google.protobuf.FieldMask update_mask = 2; +} + +// Request to delete CachedContent. +message DeleteCachedContentRequest { + // Required. The resource name referring to the content cache entry + // Format: `cachedContents/{id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "generativelanguage.googleapis.com/CachedContent" + } + ]; +} diff --git a/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/cached_content.proto b/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/cached_content.proto new file mode 100644 index 00000000000..3d5ec8c3ba4 --- /dev/null +++ b/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/cached_content.proto @@ -0,0 +1,125 @@ +// Copyright 2024 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.ai.generativelanguage.v1beta; + +import "google/ai/generativelanguage/v1beta/content.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb;generativelanguagepb"; +option java_multiple_files = true; +option java_outer_classname = "CachedContentProto"; +option java_package = "com.google.ai.generativelanguage.v1beta"; + +// Content that has been preprocessed and can be used in subsequent request +// to GenerativeService. +// +// Cached content can be only used with model it was created for. +message CachedContent { + option (google.api.resource) = { + type: "generativelanguage.googleapis.com/CachedContent" + pattern: "cachedContents/{id}" + plural: "cachedContents" + singular: "cachedContent" + }; + + // Metadata on the usage of the cached content. + message UsageMetadata { + // Total number of tokens that the cached content consumes. + int32 total_token_count = 1; + } + + // Specifies when this resource will expire. + oneof expiration { + // Timestamp in UTC of when this resource is considered expired. + // This is *always* provided on output, regardless of what was sent + // on input. + google.protobuf.Timestamp expire_time = 9; + + // Input only. New TTL for this resource, input only. + google.protobuf.Duration ttl = 10 + [(google.api.field_behavior) = INPUT_ONLY]; + } + + // Optional. Identifier. The resource name referring to the cached content. + // Format: `cachedContents/{id}` + optional string name = 1 [ + (google.api.field_behavior) = IDENTIFIER, + (google.api.field_behavior) = OPTIONAL + ]; + + // Optional. Immutable. The user-generated meaningful display name of the + // cached content. Maximum 128 Unicode characters. + optional string display_name = 11 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Immutable. The name of the `Model` to use for cached content + // Format: `models/{model}` + optional string model = 2 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "generativelanguage.googleapis.com/Model" + } + ]; + + // Optional. Input only. Immutable. Developer set system instruction. + // Currently text only. + optional Content system_instruction = 3 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = INPUT_ONLY + ]; + + // Optional. Input only. Immutable. The content to cache. + repeated Content contents = 4 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = INPUT_ONLY + ]; + + // Optional. Input only. Immutable. A list of `Tools` the model may use to + // generate the next response + repeated Tool tools = 5 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = INPUT_ONLY + ]; + + // Optional. Input only. Immutable. Tool config. This config is shared for all + // tools. + optional ToolConfig tool_config = 6 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = INPUT_ONLY + ]; + + // Output only. Creation time of the cache entry. + google.protobuf.Timestamp create_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. When the cache entry was last updated in UTC time. + google.protobuf.Timestamp update_time = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Metadata on the usage of the cached content. + UsageMetadata usage_metadata = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/content.proto b/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/content.proto index 861b9359150..52665fa977a 100644 --- a/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/content.proto +++ b/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/content.proto @@ -162,7 +162,7 @@ message FunctionCallingConfig { MODE_UNSPECIFIED = 0; // Default model behavior, model decides to predict either a function call - // or a natural language repspose. + // or a natural language response. AUTO = 1; // Model is constrained to always predicting a function call only. diff --git a/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/generative_service.proto b/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/generative_service.proto index b9ba40ae435..8270e830ed7 100644 --- a/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/generative_service.proto +++ b/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/generative_service.proto @@ -188,6 +188,17 @@ message GenerateContentRequest { // Optional. Configuration options for model generation and outputs. optional GenerationConfig generation_config = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The name of the cached content used as context to serve the + // prediction. Note: only used in explicit caching, where users can have + // control over caching (e.g. what content to cache) and enjoy guaranteed cost + // savings. Format: `cachedContents/{cachedContent}` + optional string cached_content = 9 [ + (google.api.field_behavior) = OPTIONAL, + (google.api.resource_reference) = { + type: "generativelanguage.googleapis.com/CachedContent" + } + ]; } // Configuration options for model generation and outputs. Not all parameters @@ -324,9 +335,15 @@ message GenerateContentResponse { // Metadata on the generation request's token usage. message UsageMetadata { - // Number of tokens in the prompt. + // Number of tokens in the prompt. When cached_content is set, this is still + // the total effective prompt size. I.e. this includes the number of tokens + // in the cached content. int32 prompt_token_count = 1; + // Number of tokens in the cached part of the prompt, i.e. in the cached + // content. + int32 cached_content_token_count = 4; + // Total number of tokens across the generated candidates. int32 candidates_token_count = 2; @@ -704,6 +721,12 @@ message CountTokensRequest { message CountTokensResponse { // The number of tokens that the `model` tokenizes the `prompt` into. // - // Always non-negative. + // Always non-negative. When cached_content is set, this is still the total + // effective prompt size. I.e. this includes the number of tokens in the + // cached content. int32 total_tokens = 1; + + // Number of tokens in the cached part of the prompt, i.e. in the cached + // content. + int32 cached_content_token_count = 5; } diff --git a/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/model.proto b/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/model.proto index 5320db5a2aa..407dcc165e2 100644 --- a/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/model.proto +++ b/packages/google-ai-generativelanguage/protos/google/ai/generativelanguage/v1beta/model.proto @@ -77,7 +77,7 @@ message Model { // Controls the randomness of the output. // - // Values can range over `[0.0,1.0]`, inclusive. A value closer to `1.0` will + // Values can range over `[0.0,2.0]`, inclusive. A higher value will // produce responses that are more varied, while a value closer to `0.0` will // typically result in less surprising responses from the model. // This value specifies default to be used by the backend while making the diff --git a/packages/google-ai-generativelanguage/protos/protos.d.ts b/packages/google-ai-generativelanguage/protos/protos.d.ts index b45ccd9a729..082e9198f60 100644 --- a/packages/google-ai-generativelanguage/protos/protos.d.ts +++ b/packages/google-ai-generativelanguage/protos/protos.d.ts @@ -2960,228 +2960,1014 @@ export namespace google { /** Namespace v1beta. */ namespace v1beta { - /** Properties of a CitationMetadata. */ - interface ICitationMetadata { + /** Represents a CacheService */ + class CacheService extends $protobuf.rpc.Service { + + /** + * Constructs a new CacheService service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new CacheService service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): CacheService; + + /** + * Calls ListCachedContents. + * @param request ListCachedContentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListCachedContentsResponse + */ + public listCachedContents(request: google.ai.generativelanguage.v1beta.IListCachedContentsRequest, callback: google.ai.generativelanguage.v1beta.CacheService.ListCachedContentsCallback): void; + + /** + * Calls ListCachedContents. + * @param request ListCachedContentsRequest message or plain object + * @returns Promise + */ + public listCachedContents(request: google.ai.generativelanguage.v1beta.IListCachedContentsRequest): Promise; + + /** + * Calls CreateCachedContent. + * @param request CreateCachedContentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CachedContent + */ + public createCachedContent(request: google.ai.generativelanguage.v1beta.ICreateCachedContentRequest, callback: google.ai.generativelanguage.v1beta.CacheService.CreateCachedContentCallback): void; + + /** + * Calls CreateCachedContent. + * @param request CreateCachedContentRequest message or plain object + * @returns Promise + */ + public createCachedContent(request: google.ai.generativelanguage.v1beta.ICreateCachedContentRequest): Promise; + + /** + * Calls GetCachedContent. + * @param request GetCachedContentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CachedContent + */ + public getCachedContent(request: google.ai.generativelanguage.v1beta.IGetCachedContentRequest, callback: google.ai.generativelanguage.v1beta.CacheService.GetCachedContentCallback): void; + + /** + * Calls GetCachedContent. + * @param request GetCachedContentRequest message or plain object + * @returns Promise + */ + public getCachedContent(request: google.ai.generativelanguage.v1beta.IGetCachedContentRequest): Promise; + + /** + * Calls UpdateCachedContent. + * @param request UpdateCachedContentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CachedContent + */ + public updateCachedContent(request: google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest, callback: google.ai.generativelanguage.v1beta.CacheService.UpdateCachedContentCallback): void; + + /** + * Calls UpdateCachedContent. + * @param request UpdateCachedContentRequest message or plain object + * @returns Promise + */ + public updateCachedContent(request: google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest): Promise; + + /** + * Calls DeleteCachedContent. + * @param request DeleteCachedContentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteCachedContent(request: google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest, callback: google.ai.generativelanguage.v1beta.CacheService.DeleteCachedContentCallback): void; + + /** + * Calls DeleteCachedContent. + * @param request DeleteCachedContentRequest message or plain object + * @returns Promise + */ + public deleteCachedContent(request: google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest): Promise; + } + + namespace CacheService { + + /** + * Callback as used by {@link google.ai.generativelanguage.v1beta.CacheService|listCachedContents}. + * @param error Error, if any + * @param [response] ListCachedContentsResponse + */ + type ListCachedContentsCallback = (error: (Error|null), response?: google.ai.generativelanguage.v1beta.ListCachedContentsResponse) => void; + + /** + * Callback as used by {@link google.ai.generativelanguage.v1beta.CacheService|createCachedContent}. + * @param error Error, if any + * @param [response] CachedContent + */ + type CreateCachedContentCallback = (error: (Error|null), response?: google.ai.generativelanguage.v1beta.CachedContent) => void; + + /** + * Callback as used by {@link google.ai.generativelanguage.v1beta.CacheService|getCachedContent}. + * @param error Error, if any + * @param [response] CachedContent + */ + type GetCachedContentCallback = (error: (Error|null), response?: google.ai.generativelanguage.v1beta.CachedContent) => void; + + /** + * Callback as used by {@link google.ai.generativelanguage.v1beta.CacheService|updateCachedContent}. + * @param error Error, if any + * @param [response] CachedContent + */ + type UpdateCachedContentCallback = (error: (Error|null), response?: google.ai.generativelanguage.v1beta.CachedContent) => void; + + /** + * Callback as used by {@link google.ai.generativelanguage.v1beta.CacheService|deleteCachedContent}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteCachedContentCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + } + + /** Properties of a ListCachedContentsRequest. */ + interface IListCachedContentsRequest { + + /** ListCachedContentsRequest pageSize */ + pageSize?: (number|null); + + /** ListCachedContentsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListCachedContentsRequest. */ + class ListCachedContentsRequest implements IListCachedContentsRequest { + + /** + * Constructs a new ListCachedContentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.ai.generativelanguage.v1beta.IListCachedContentsRequest); + + /** ListCachedContentsRequest pageSize. */ + public pageSize: number; + + /** ListCachedContentsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListCachedContentsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCachedContentsRequest instance + */ + public static create(properties?: google.ai.generativelanguage.v1beta.IListCachedContentsRequest): google.ai.generativelanguage.v1beta.ListCachedContentsRequest; + + /** + * Encodes the specified ListCachedContentsRequest message. Does not implicitly {@link google.ai.generativelanguage.v1beta.ListCachedContentsRequest.verify|verify} messages. + * @param message ListCachedContentsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.ai.generativelanguage.v1beta.IListCachedContentsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCachedContentsRequest message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.ListCachedContentsRequest.verify|verify} messages. + * @param message ListCachedContentsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.IListCachedContentsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCachedContentsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCachedContentsRequest + * @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.ai.generativelanguage.v1beta.ListCachedContentsRequest; + + /** + * Decodes a ListCachedContentsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCachedContentsRequest + * @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.ai.generativelanguage.v1beta.ListCachedContentsRequest; + + /** + * Verifies a ListCachedContentsRequest 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 a ListCachedContentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCachedContentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.ListCachedContentsRequest; + + /** + * Creates a plain object from a ListCachedContentsRequest message. Also converts values to other types if specified. + * @param message ListCachedContentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.ai.generativelanguage.v1beta.ListCachedContentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCachedContentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListCachedContentsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListCachedContentsResponse. */ + interface IListCachedContentsResponse { + + /** ListCachedContentsResponse cachedContents */ + cachedContents?: (google.ai.generativelanguage.v1beta.ICachedContent[]|null); + + /** ListCachedContentsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListCachedContentsResponse. */ + class ListCachedContentsResponse implements IListCachedContentsResponse { + + /** + * Constructs a new ListCachedContentsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.ai.generativelanguage.v1beta.IListCachedContentsResponse); + + /** ListCachedContentsResponse cachedContents. */ + public cachedContents: google.ai.generativelanguage.v1beta.ICachedContent[]; + + /** ListCachedContentsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListCachedContentsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCachedContentsResponse instance + */ + public static create(properties?: google.ai.generativelanguage.v1beta.IListCachedContentsResponse): google.ai.generativelanguage.v1beta.ListCachedContentsResponse; + + /** + * Encodes the specified ListCachedContentsResponse message. Does not implicitly {@link google.ai.generativelanguage.v1beta.ListCachedContentsResponse.verify|verify} messages. + * @param message ListCachedContentsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.ai.generativelanguage.v1beta.IListCachedContentsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCachedContentsResponse message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.ListCachedContentsResponse.verify|verify} messages. + * @param message ListCachedContentsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.IListCachedContentsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCachedContentsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCachedContentsResponse + * @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.ai.generativelanguage.v1beta.ListCachedContentsResponse; + + /** + * Decodes a ListCachedContentsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCachedContentsResponse + * @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.ai.generativelanguage.v1beta.ListCachedContentsResponse; + + /** + * Verifies a ListCachedContentsResponse 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 a ListCachedContentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCachedContentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.ListCachedContentsResponse; + + /** + * Creates a plain object from a ListCachedContentsResponse message. Also converts values to other types if specified. + * @param message ListCachedContentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.ai.generativelanguage.v1beta.ListCachedContentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCachedContentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListCachedContentsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CreateCachedContentRequest. */ + interface ICreateCachedContentRequest { + + /** CreateCachedContentRequest cachedContent */ + cachedContent?: (google.ai.generativelanguage.v1beta.ICachedContent|null); + } + + /** Represents a CreateCachedContentRequest. */ + class CreateCachedContentRequest implements ICreateCachedContentRequest { + + /** + * Constructs a new CreateCachedContentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.ai.generativelanguage.v1beta.ICreateCachedContentRequest); + + /** CreateCachedContentRequest cachedContent. */ + public cachedContent?: (google.ai.generativelanguage.v1beta.ICachedContent|null); + + /** + * Creates a new CreateCachedContentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateCachedContentRequest instance + */ + public static create(properties?: google.ai.generativelanguage.v1beta.ICreateCachedContentRequest): google.ai.generativelanguage.v1beta.CreateCachedContentRequest; + + /** + * Encodes the specified CreateCachedContentRequest message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CreateCachedContentRequest.verify|verify} messages. + * @param message CreateCachedContentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.ai.generativelanguage.v1beta.ICreateCachedContentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateCachedContentRequest message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CreateCachedContentRequest.verify|verify} messages. + * @param message CreateCachedContentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.ICreateCachedContentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateCachedContentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateCachedContentRequest + * @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.ai.generativelanguage.v1beta.CreateCachedContentRequest; + + /** + * Decodes a CreateCachedContentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateCachedContentRequest + * @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.ai.generativelanguage.v1beta.CreateCachedContentRequest; + + /** + * Verifies a CreateCachedContentRequest 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 a CreateCachedContentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateCachedContentRequest + */ + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.CreateCachedContentRequest; + + /** + * Creates a plain object from a CreateCachedContentRequest message. Also converts values to other types if specified. + * @param message CreateCachedContentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.ai.generativelanguage.v1beta.CreateCachedContentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateCachedContentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateCachedContentRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetCachedContentRequest. */ + interface IGetCachedContentRequest { + + /** GetCachedContentRequest name */ + name?: (string|null); + } + + /** Represents a GetCachedContentRequest. */ + class GetCachedContentRequest implements IGetCachedContentRequest { + + /** + * Constructs a new GetCachedContentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.ai.generativelanguage.v1beta.IGetCachedContentRequest); + + /** GetCachedContentRequest name. */ + public name: string; + + /** + * Creates a new GetCachedContentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetCachedContentRequest instance + */ + public static create(properties?: google.ai.generativelanguage.v1beta.IGetCachedContentRequest): google.ai.generativelanguage.v1beta.GetCachedContentRequest; + + /** + * Encodes the specified GetCachedContentRequest message. Does not implicitly {@link google.ai.generativelanguage.v1beta.GetCachedContentRequest.verify|verify} messages. + * @param message GetCachedContentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.ai.generativelanguage.v1beta.IGetCachedContentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetCachedContentRequest message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.GetCachedContentRequest.verify|verify} messages. + * @param message GetCachedContentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.IGetCachedContentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetCachedContentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetCachedContentRequest + * @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.ai.generativelanguage.v1beta.GetCachedContentRequest; + + /** + * Decodes a GetCachedContentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetCachedContentRequest + * @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.ai.generativelanguage.v1beta.GetCachedContentRequest; + + /** + * Verifies a GetCachedContentRequest 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 a GetCachedContentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetCachedContentRequest + */ + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.GetCachedContentRequest; + + /** + * Creates a plain object from a GetCachedContentRequest message. Also converts values to other types if specified. + * @param message GetCachedContentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.ai.generativelanguage.v1beta.GetCachedContentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetCachedContentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetCachedContentRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateCachedContentRequest. */ + interface IUpdateCachedContentRequest { + + /** UpdateCachedContentRequest cachedContent */ + cachedContent?: (google.ai.generativelanguage.v1beta.ICachedContent|null); + + /** UpdateCachedContentRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateCachedContentRequest. */ + class UpdateCachedContentRequest implements IUpdateCachedContentRequest { + + /** + * Constructs a new UpdateCachedContentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest); - /** CitationMetadata citationSources */ - citationSources?: (google.ai.generativelanguage.v1beta.ICitationSource[]|null); + /** UpdateCachedContentRequest cachedContent. */ + public cachedContent?: (google.ai.generativelanguage.v1beta.ICachedContent|null); + + /** UpdateCachedContentRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateCachedContentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateCachedContentRequest instance + */ + public static create(properties?: google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest): google.ai.generativelanguage.v1beta.UpdateCachedContentRequest; + + /** + * Encodes the specified UpdateCachedContentRequest message. Does not implicitly {@link google.ai.generativelanguage.v1beta.UpdateCachedContentRequest.verify|verify} messages. + * @param message UpdateCachedContentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateCachedContentRequest message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.UpdateCachedContentRequest.verify|verify} messages. + * @param message UpdateCachedContentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateCachedContentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateCachedContentRequest + * @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.ai.generativelanguage.v1beta.UpdateCachedContentRequest; + + /** + * Decodes an UpdateCachedContentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateCachedContentRequest + * @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.ai.generativelanguage.v1beta.UpdateCachedContentRequest; + + /** + * Verifies an UpdateCachedContentRequest 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 UpdateCachedContentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateCachedContentRequest + */ + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.UpdateCachedContentRequest; + + /** + * Creates a plain object from an UpdateCachedContentRequest message. Also converts values to other types if specified. + * @param message UpdateCachedContentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.ai.generativelanguage.v1beta.UpdateCachedContentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateCachedContentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateCachedContentRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } - /** Represents a CitationMetadata. */ - class CitationMetadata implements ICitationMetadata { + /** Properties of a DeleteCachedContentRequest. */ + interface IDeleteCachedContentRequest { + + /** DeleteCachedContentRequest name */ + name?: (string|null); + } + + /** Represents a DeleteCachedContentRequest. */ + class DeleteCachedContentRequest implements IDeleteCachedContentRequest { /** - * Constructs a new CitationMetadata. + * Constructs a new DeleteCachedContentRequest. * @param [properties] Properties to set */ - constructor(properties?: google.ai.generativelanguage.v1beta.ICitationMetadata); + constructor(properties?: google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest); - /** CitationMetadata citationSources. */ - public citationSources: google.ai.generativelanguage.v1beta.ICitationSource[]; + /** DeleteCachedContentRequest name. */ + public name: string; /** - * Creates a new CitationMetadata instance using the specified properties. + * Creates a new DeleteCachedContentRequest instance using the specified properties. * @param [properties] Properties to set - * @returns CitationMetadata instance + * @returns DeleteCachedContentRequest instance */ - public static create(properties?: google.ai.generativelanguage.v1beta.ICitationMetadata): google.ai.generativelanguage.v1beta.CitationMetadata; + public static create(properties?: google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest): google.ai.generativelanguage.v1beta.DeleteCachedContentRequest; /** - * Encodes the specified CitationMetadata message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationMetadata.verify|verify} messages. - * @param message CitationMetadata message or plain object to encode + * Encodes the specified DeleteCachedContentRequest message. Does not implicitly {@link google.ai.generativelanguage.v1beta.DeleteCachedContentRequest.verify|verify} messages. + * @param message DeleteCachedContentRequest message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.ai.generativelanguage.v1beta.ICitationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified CitationMetadata message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationMetadata.verify|verify} messages. - * @param message CitationMetadata message or plain object to encode + * Encodes the specified DeleteCachedContentRequest message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.DeleteCachedContentRequest.verify|verify} messages. + * @param message DeleteCachedContentRequest message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.ai.generativelanguage.v1beta.ICitationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a CitationMetadata message from the specified reader or buffer. + * Decodes a DeleteCachedContentRequest message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns CitationMetadata + * @returns DeleteCachedContentRequest * @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.ai.generativelanguage.v1beta.CitationMetadata; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.ai.generativelanguage.v1beta.DeleteCachedContentRequest; /** - * Decodes a CitationMetadata message from the specified reader or buffer, length delimited. + * Decodes a DeleteCachedContentRequest message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns CitationMetadata + * @returns DeleteCachedContentRequest * @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.ai.generativelanguage.v1beta.CitationMetadata; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.ai.generativelanguage.v1beta.DeleteCachedContentRequest; /** - * Verifies a CitationMetadata message. + * Verifies a DeleteCachedContentRequest 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 a CitationMetadata message from a plain object. Also converts values to their respective internal types. + * Creates a DeleteCachedContentRequest message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns CitationMetadata + * @returns DeleteCachedContentRequest */ - public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.CitationMetadata; + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.DeleteCachedContentRequest; /** - * Creates a plain object from a CitationMetadata message. Also converts values to other types if specified. - * @param message CitationMetadata + * Creates a plain object from a DeleteCachedContentRequest message. Also converts values to other types if specified. + * @param message DeleteCachedContentRequest * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.ai.generativelanguage.v1beta.CitationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.ai.generativelanguage.v1beta.DeleteCachedContentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this CitationMetadata to JSON. + * Converts this DeleteCachedContentRequest to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; /** - * Gets the default type url for CitationMetadata + * Gets the default type url for DeleteCachedContentRequest * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns The default type url */ public static getTypeUrl(typeUrlPrefix?: string): string; } - /** Properties of a CitationSource. */ - interface ICitationSource { + /** Properties of a CachedContent. */ + interface ICachedContent { - /** CitationSource startIndex */ - startIndex?: (number|null); + /** CachedContent expireTime */ + expireTime?: (google.protobuf.ITimestamp|null); - /** CitationSource endIndex */ - endIndex?: (number|null); + /** CachedContent ttl */ + ttl?: (google.protobuf.IDuration|null); - /** CitationSource uri */ - uri?: (string|null); + /** CachedContent name */ + name?: (string|null); - /** CitationSource license */ - license?: (string|null); + /** CachedContent displayName */ + displayName?: (string|null); + + /** CachedContent model */ + model?: (string|null); + + /** CachedContent systemInstruction */ + systemInstruction?: (google.ai.generativelanguage.v1beta.IContent|null); + + /** CachedContent contents */ + contents?: (google.ai.generativelanguage.v1beta.IContent[]|null); + + /** CachedContent tools */ + tools?: (google.ai.generativelanguage.v1beta.ITool[]|null); + + /** CachedContent toolConfig */ + toolConfig?: (google.ai.generativelanguage.v1beta.IToolConfig|null); + + /** CachedContent createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** CachedContent updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** CachedContent usageMetadata */ + usageMetadata?: (google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata|null); } - /** Represents a CitationSource. */ - class CitationSource implements ICitationSource { + /** Represents a CachedContent. */ + class CachedContent implements ICachedContent { /** - * Constructs a new CitationSource. + * Constructs a new CachedContent. * @param [properties] Properties to set */ - constructor(properties?: google.ai.generativelanguage.v1beta.ICitationSource); + constructor(properties?: google.ai.generativelanguage.v1beta.ICachedContent); - /** CitationSource startIndex. */ - public startIndex?: (number|null); + /** CachedContent expireTime. */ + public expireTime?: (google.protobuf.ITimestamp|null); - /** CitationSource endIndex. */ - public endIndex?: (number|null); + /** CachedContent ttl. */ + public ttl?: (google.protobuf.IDuration|null); - /** CitationSource uri. */ - public uri?: (string|null); + /** CachedContent name. */ + public name?: (string|null); - /** CitationSource license. */ - public license?: (string|null); + /** CachedContent displayName. */ + public displayName?: (string|null); - /** CitationSource _startIndex. */ - public _startIndex?: "startIndex"; + /** CachedContent model. */ + public model?: (string|null); - /** CitationSource _endIndex. */ - public _endIndex?: "endIndex"; + /** CachedContent systemInstruction. */ + public systemInstruction?: (google.ai.generativelanguage.v1beta.IContent|null); - /** CitationSource _uri. */ - public _uri?: "uri"; + /** CachedContent contents. */ + public contents: google.ai.generativelanguage.v1beta.IContent[]; - /** CitationSource _license. */ - public _license?: "license"; + /** CachedContent tools. */ + public tools: google.ai.generativelanguage.v1beta.ITool[]; + + /** CachedContent toolConfig. */ + public toolConfig?: (google.ai.generativelanguage.v1beta.IToolConfig|null); + + /** CachedContent createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** CachedContent updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** CachedContent usageMetadata. */ + public usageMetadata?: (google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata|null); + + /** CachedContent expiration. */ + public expiration?: ("expireTime"|"ttl"); + + /** CachedContent _name. */ + public _name?: "name"; + + /** CachedContent _displayName. */ + public _displayName?: "displayName"; + + /** CachedContent _model. */ + public _model?: "model"; + + /** CachedContent _systemInstruction. */ + public _systemInstruction?: "systemInstruction"; + + /** CachedContent _toolConfig. */ + public _toolConfig?: "toolConfig"; /** - * Creates a new CitationSource instance using the specified properties. + * Creates a new CachedContent instance using the specified properties. * @param [properties] Properties to set - * @returns CitationSource instance + * @returns CachedContent instance */ - public static create(properties?: google.ai.generativelanguage.v1beta.ICitationSource): google.ai.generativelanguage.v1beta.CitationSource; + public static create(properties?: google.ai.generativelanguage.v1beta.ICachedContent): google.ai.generativelanguage.v1beta.CachedContent; /** - * Encodes the specified CitationSource message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationSource.verify|verify} messages. - * @param message CitationSource message or plain object to encode + * Encodes the specified CachedContent message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CachedContent.verify|verify} messages. + * @param message CachedContent message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.ai.generativelanguage.v1beta.ICitationSource, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.ai.generativelanguage.v1beta.ICachedContent, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified CitationSource message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationSource.verify|verify} messages. - * @param message CitationSource message or plain object to encode + * Encodes the specified CachedContent message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CachedContent.verify|verify} messages. + * @param message CachedContent message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.ai.generativelanguage.v1beta.ICitationSource, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.ICachedContent, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a CitationSource message from the specified reader or buffer. + * Decodes a CachedContent message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns CitationSource + * @returns CachedContent * @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.ai.generativelanguage.v1beta.CitationSource; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.ai.generativelanguage.v1beta.CachedContent; /** - * Decodes a CitationSource message from the specified reader or buffer, length delimited. + * Decodes a CachedContent message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns CitationSource + * @returns CachedContent * @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.ai.generativelanguage.v1beta.CitationSource; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.ai.generativelanguage.v1beta.CachedContent; /** - * Verifies a CitationSource message. + * Verifies a CachedContent 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 a CitationSource message from a plain object. Also converts values to their respective internal types. + * Creates a CachedContent message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns CitationSource + * @returns CachedContent */ - public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.CitationSource; + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.CachedContent; /** - * Creates a plain object from a CitationSource message. Also converts values to other types if specified. - * @param message CitationSource + * Creates a plain object from a CachedContent message. Also converts values to other types if specified. + * @param message CachedContent * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.ai.generativelanguage.v1beta.CitationSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.ai.generativelanguage.v1beta.CachedContent, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CachedContent to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CachedContent + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CachedContent { + + /** Properties of a UsageMetadata. */ + interface IUsageMetadata { + + /** UsageMetadata totalTokenCount */ + totalTokenCount?: (number|null); + } + + /** Represents a UsageMetadata. */ + class UsageMetadata implements IUsageMetadata { + + /** + * Constructs a new UsageMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata); + + /** UsageMetadata totalTokenCount. */ + public totalTokenCount: number; + + /** + * Creates a new UsageMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns UsageMetadata instance + */ + public static create(properties?: google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata): google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata; + + /** + * Encodes the specified UsageMetadata message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata.verify|verify} messages. + * @param message UsageMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UsageMetadata message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata.verify|verify} messages. + * @param message UsageMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UsageMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UsageMetadata + * @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.ai.generativelanguage.v1beta.CachedContent.UsageMetadata; + + /** + * Decodes a UsageMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UsageMetadata + * @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.ai.generativelanguage.v1beta.CachedContent.UsageMetadata; + + /** + * Verifies a UsageMetadata 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 a UsageMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UsageMetadata + */ + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata; - /** - * Converts this CitationSource to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; + /** + * Creates a plain object from a UsageMetadata message. Also converts values to other types if specified. + * @param message UsageMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; - /** - * Gets the default type url for CitationSource - * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns The default type url - */ - public static getTypeUrl(typeUrlPrefix?: string): string; + /** + * Converts this UsageMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UsageMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Type enum. */ @@ -4529,70 +5315,294 @@ export namespace google { public static create(properties?: google.ai.generativelanguage.v1beta.IGroundingPassages): google.ai.generativelanguage.v1beta.GroundingPassages; /** - * Encodes the specified GroundingPassages message. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassages.verify|verify} messages. - * @param message GroundingPassages message or plain object to encode + * Encodes the specified GroundingPassages message. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassages.verify|verify} messages. + * @param message GroundingPassages message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.ai.generativelanguage.v1beta.IGroundingPassages, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GroundingPassages message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassages.verify|verify} messages. + * @param message GroundingPassages message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.IGroundingPassages, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GroundingPassages message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GroundingPassages + * @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.ai.generativelanguage.v1beta.GroundingPassages; + + /** + * Decodes a GroundingPassages message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GroundingPassages + * @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.ai.generativelanguage.v1beta.GroundingPassages; + + /** + * Verifies a GroundingPassages 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 a GroundingPassages message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GroundingPassages + */ + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.GroundingPassages; + + /** + * Creates a plain object from a GroundingPassages message. Also converts values to other types if specified. + * @param message GroundingPassages + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.ai.generativelanguage.v1beta.GroundingPassages, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GroundingPassages to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GroundingPassages + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CitationMetadata. */ + interface ICitationMetadata { + + /** CitationMetadata citationSources */ + citationSources?: (google.ai.generativelanguage.v1beta.ICitationSource[]|null); + } + + /** Represents a CitationMetadata. */ + class CitationMetadata implements ICitationMetadata { + + /** + * Constructs a new CitationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.ai.generativelanguage.v1beta.ICitationMetadata); + + /** CitationMetadata citationSources. */ + public citationSources: google.ai.generativelanguage.v1beta.ICitationSource[]; + + /** + * Creates a new CitationMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns CitationMetadata instance + */ + public static create(properties?: google.ai.generativelanguage.v1beta.ICitationMetadata): google.ai.generativelanguage.v1beta.CitationMetadata; + + /** + * Encodes the specified CitationMetadata message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationMetadata.verify|verify} messages. + * @param message CitationMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.ai.generativelanguage.v1beta.ICitationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CitationMetadata message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationMetadata.verify|verify} messages. + * @param message CitationMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.ICitationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CitationMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CitationMetadata + * @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.ai.generativelanguage.v1beta.CitationMetadata; + + /** + * Decodes a CitationMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CitationMetadata + * @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.ai.generativelanguage.v1beta.CitationMetadata; + + /** + * Verifies a CitationMetadata 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 a CitationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CitationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.CitationMetadata; + + /** + * Creates a plain object from a CitationMetadata message. Also converts values to other types if specified. + * @param message CitationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.ai.generativelanguage.v1beta.CitationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CitationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CitationMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CitationSource. */ + interface ICitationSource { + + /** CitationSource startIndex */ + startIndex?: (number|null); + + /** CitationSource endIndex */ + endIndex?: (number|null); + + /** CitationSource uri */ + uri?: (string|null); + + /** CitationSource license */ + license?: (string|null); + } + + /** Represents a CitationSource. */ + class CitationSource implements ICitationSource { + + /** + * Constructs a new CitationSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.ai.generativelanguage.v1beta.ICitationSource); + + /** CitationSource startIndex. */ + public startIndex?: (number|null); + + /** CitationSource endIndex. */ + public endIndex?: (number|null); + + /** CitationSource uri. */ + public uri?: (string|null); + + /** CitationSource license. */ + public license?: (string|null); + + /** CitationSource _startIndex. */ + public _startIndex?: "startIndex"; + + /** CitationSource _endIndex. */ + public _endIndex?: "endIndex"; + + /** CitationSource _uri. */ + public _uri?: "uri"; + + /** CitationSource _license. */ + public _license?: "license"; + + /** + * Creates a new CitationSource instance using the specified properties. + * @param [properties] Properties to set + * @returns CitationSource instance + */ + public static create(properties?: google.ai.generativelanguage.v1beta.ICitationSource): google.ai.generativelanguage.v1beta.CitationSource; + + /** + * Encodes the specified CitationSource message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationSource.verify|verify} messages. + * @param message CitationSource message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.ai.generativelanguage.v1beta.IGroundingPassages, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.ai.generativelanguage.v1beta.ICitationSource, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified GroundingPassages message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassages.verify|verify} messages. - * @param message GroundingPassages message or plain object to encode + * Encodes the specified CitationSource message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationSource.verify|verify} messages. + * @param message CitationSource message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.ai.generativelanguage.v1beta.IGroundingPassages, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.ai.generativelanguage.v1beta.ICitationSource, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a GroundingPassages message from the specified reader or buffer. + * Decodes a CitationSource message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns GroundingPassages + * @returns CitationSource * @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.ai.generativelanguage.v1beta.GroundingPassages; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.ai.generativelanguage.v1beta.CitationSource; /** - * Decodes a GroundingPassages message from the specified reader or buffer, length delimited. + * Decodes a CitationSource message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns GroundingPassages + * @returns CitationSource * @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.ai.generativelanguage.v1beta.GroundingPassages; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.ai.generativelanguage.v1beta.CitationSource; /** - * Verifies a GroundingPassages message. + * Verifies a CitationSource 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 a GroundingPassages message from a plain object. Also converts values to their respective internal types. + * Creates a CitationSource message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns GroundingPassages + * @returns CitationSource */ - public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.GroundingPassages; + public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.CitationSource; /** - * Creates a plain object from a GroundingPassages message. Also converts values to other types if specified. - * @param message GroundingPassages + * Creates a plain object from a CitationSource message. Also converts values to other types if specified. + * @param message CitationSource * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.ai.generativelanguage.v1beta.GroundingPassages, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.ai.generativelanguage.v1beta.CitationSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this GroundingPassages to JSON. + * Converts this CitationSource to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; /** - * Gets the default type url for GroundingPassages + * Gets the default type url for CitationSource * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns The default type url */ @@ -7068,6 +8078,9 @@ export namespace google { /** GenerateContentRequest generationConfig */ generationConfig?: (google.ai.generativelanguage.v1beta.IGenerationConfig|null); + + /** GenerateContentRequest cachedContent */ + cachedContent?: (string|null); } /** Represents a GenerateContentRequest. */ @@ -7100,12 +8113,18 @@ export namespace google { /** GenerateContentRequest generationConfig. */ public generationConfig?: (google.ai.generativelanguage.v1beta.IGenerationConfig|null); + /** GenerateContentRequest cachedContent. */ + public cachedContent?: (string|null); + /** GenerateContentRequest _systemInstruction. */ public _systemInstruction?: "systemInstruction"; /** GenerateContentRequest _generationConfig. */ public _generationConfig?: "generationConfig"; + /** GenerateContentRequest _cachedContent. */ + public _cachedContent?: "cachedContent"; + /** * Creates a new GenerateContentRequest instance using the specified properties. * @param [properties] Properties to set @@ -7695,6 +8714,9 @@ export namespace google { /** UsageMetadata promptTokenCount */ promptTokenCount?: (number|null); + /** UsageMetadata cachedContentTokenCount */ + cachedContentTokenCount?: (number|null); + /** UsageMetadata candidatesTokenCount */ candidatesTokenCount?: (number|null); @@ -7714,6 +8736,9 @@ export namespace google { /** UsageMetadata promptTokenCount. */ public promptTokenCount: number; + /** UsageMetadata cachedContentTokenCount. */ + public cachedContentTokenCount: number; + /** UsageMetadata candidatesTokenCount. */ public candidatesTokenCount: number; @@ -9388,6 +10413,9 @@ export namespace google { /** CountTokensResponse totalTokens */ totalTokens?: (number|null); + + /** CountTokensResponse cachedContentTokenCount */ + cachedContentTokenCount?: (number|null); } /** Represents a CountTokensResponse. */ @@ -9402,6 +10430,9 @@ export namespace google { /** CountTokensResponse totalTokens. */ public totalTokens: number; + /** CountTokensResponse cachedContentTokenCount. */ + public cachedContentTokenCount: number; + /** * Creates a new CountTokensResponse instance using the specified properties. * @param [properties] Properties to set @@ -34322,109 +35353,6 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } - /** Properties of an Any. */ - interface IAny { - - /** Any type_url */ - type_url?: (string|null); - - /** Any value */ - value?: (Uint8Array|string|null); - } - - /** Represents an Any. */ - class Any implements IAny { - - /** - * Constructs a new Any. - * @param [properties] Properties to set - */ - constructor(properties?: google.protobuf.IAny); - - /** Any type_url. */ - public type_url: string; - - /** Any value. */ - public value: (Uint8Array|string); - - /** - * Creates a new Any instance using the specified properties. - * @param [properties] Properties to set - * @returns Any instance - */ - public static create(properties?: google.protobuf.IAny): google.protobuf.Any; - - /** - * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. - * @param message Any message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: google.protobuf.IAny, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. - * @param message Any message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: google.protobuf.IAny, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes an Any message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns Any - * @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.protobuf.Any; - - /** - * Decodes an Any message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns Any - * @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.protobuf.Any; - - /** - * Verifies an Any 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 Any message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns Any - */ - public static fromObject(object: { [k: string]: any }): google.protobuf.Any; - - /** - * Creates a plain object from an Any message. Also converts values to other types if specified. - * @param message Any - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: google.protobuf.Any, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this Any to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - - /** - * Gets the default type url for Any - * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns The default type url - */ - public static getTypeUrl(typeUrlPrefix?: string): string; - } - /** Properties of an Empty. */ interface IEmpty { } @@ -34612,6 +35540,109 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of an Any. */ + interface IAny { + + /** Any type_url */ + type_url?: (string|null); + + /** Any value */ + value?: (Uint8Array|string|null); + } + + /** Represents an Any. */ + class Any implements IAny { + + /** + * Constructs a new Any. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IAny); + + /** Any type_url. */ + public type_url: string; + + /** Any value. */ + public value: (Uint8Array|string); + + /** + * Creates a new Any instance using the specified properties. + * @param [properties] Properties to set + * @returns Any instance + */ + public static create(properties?: google.protobuf.IAny): google.protobuf.Any; + + /** + * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @param message Any message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IAny, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @param message Any message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IAny, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Any message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Any + * @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.protobuf.Any; + + /** + * Decodes an Any message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Any + * @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.protobuf.Any; + + /** + * Verifies an Any 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 Any message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Any + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Any; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @param message Any + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Any, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Any to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Any + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Namespace rpc. */ diff --git a/packages/google-ai-generativelanguage/protos/protos.js b/packages/google-ai-generativelanguage/protos/protos.js index 02be69110dd..49e60cb4d34 100644 --- a/packages/google-ai-generativelanguage/protos/protos.js +++ b/packages/google-ai-generativelanguage/protos/protos.js @@ -7418,25 +7418,225 @@ */ var v1beta = {}; - v1beta.CitationMetadata = (function() { + v1beta.CacheService = (function() { /** - * Properties of a CitationMetadata. + * Constructs a new CacheService service. * @memberof google.ai.generativelanguage.v1beta - * @interface ICitationMetadata - * @property {Array.|null} [citationSources] CitationMetadata citationSources + * @classdesc Represents a CacheService + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited */ + function CacheService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (CacheService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = CacheService; /** - * Constructs a new CitationMetadata. + * Creates new CacheService service using the specified rpc implementation. + * @function create + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {CacheService} RPC service. Useful where requests and/or responses are streamed. + */ + CacheService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.ai.generativelanguage.v1beta.CacheService|listCachedContents}. + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @typedef ListCachedContentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.ai.generativelanguage.v1beta.ListCachedContentsResponse} [response] ListCachedContentsResponse + */ + + /** + * Calls ListCachedContents. + * @function listCachedContents + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @instance + * @param {google.ai.generativelanguage.v1beta.IListCachedContentsRequest} request ListCachedContentsRequest message or plain object + * @param {google.ai.generativelanguage.v1beta.CacheService.ListCachedContentsCallback} callback Node-style callback called with the error, if any, and ListCachedContentsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CacheService.prototype.listCachedContents = function listCachedContents(request, callback) { + return this.rpcCall(listCachedContents, $root.google.ai.generativelanguage.v1beta.ListCachedContentsRequest, $root.google.ai.generativelanguage.v1beta.ListCachedContentsResponse, request, callback); + }, "name", { value: "ListCachedContents" }); + + /** + * Calls ListCachedContents. + * @function listCachedContents + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @instance + * @param {google.ai.generativelanguage.v1beta.IListCachedContentsRequest} request ListCachedContentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.ai.generativelanguage.v1beta.CacheService|createCachedContent}. + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @typedef CreateCachedContentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.ai.generativelanguage.v1beta.CachedContent} [response] CachedContent + */ + + /** + * Calls CreateCachedContent. + * @function createCachedContent + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @instance + * @param {google.ai.generativelanguage.v1beta.ICreateCachedContentRequest} request CreateCachedContentRequest message or plain object + * @param {google.ai.generativelanguage.v1beta.CacheService.CreateCachedContentCallback} callback Node-style callback called with the error, if any, and CachedContent + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CacheService.prototype.createCachedContent = function createCachedContent(request, callback) { + return this.rpcCall(createCachedContent, $root.google.ai.generativelanguage.v1beta.CreateCachedContentRequest, $root.google.ai.generativelanguage.v1beta.CachedContent, request, callback); + }, "name", { value: "CreateCachedContent" }); + + /** + * Calls CreateCachedContent. + * @function createCachedContent + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @instance + * @param {google.ai.generativelanguage.v1beta.ICreateCachedContentRequest} request CreateCachedContentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.ai.generativelanguage.v1beta.CacheService|getCachedContent}. + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @typedef GetCachedContentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.ai.generativelanguage.v1beta.CachedContent} [response] CachedContent + */ + + /** + * Calls GetCachedContent. + * @function getCachedContent + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @instance + * @param {google.ai.generativelanguage.v1beta.IGetCachedContentRequest} request GetCachedContentRequest message or plain object + * @param {google.ai.generativelanguage.v1beta.CacheService.GetCachedContentCallback} callback Node-style callback called with the error, if any, and CachedContent + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CacheService.prototype.getCachedContent = function getCachedContent(request, callback) { + return this.rpcCall(getCachedContent, $root.google.ai.generativelanguage.v1beta.GetCachedContentRequest, $root.google.ai.generativelanguage.v1beta.CachedContent, request, callback); + }, "name", { value: "GetCachedContent" }); + + /** + * Calls GetCachedContent. + * @function getCachedContent + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @instance + * @param {google.ai.generativelanguage.v1beta.IGetCachedContentRequest} request GetCachedContentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.ai.generativelanguage.v1beta.CacheService|updateCachedContent}. + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @typedef UpdateCachedContentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.ai.generativelanguage.v1beta.CachedContent} [response] CachedContent + */ + + /** + * Calls UpdateCachedContent. + * @function updateCachedContent + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @instance + * @param {google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest} request UpdateCachedContentRequest message or plain object + * @param {google.ai.generativelanguage.v1beta.CacheService.UpdateCachedContentCallback} callback Node-style callback called with the error, if any, and CachedContent + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CacheService.prototype.updateCachedContent = function updateCachedContent(request, callback) { + return this.rpcCall(updateCachedContent, $root.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest, $root.google.ai.generativelanguage.v1beta.CachedContent, request, callback); + }, "name", { value: "UpdateCachedContent" }); + + /** + * Calls UpdateCachedContent. + * @function updateCachedContent + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @instance + * @param {google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest} request UpdateCachedContentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.ai.generativelanguage.v1beta.CacheService|deleteCachedContent}. + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @typedef DeleteCachedContentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteCachedContent. + * @function deleteCachedContent + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @instance + * @param {google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest} request DeleteCachedContentRequest message or plain object + * @param {google.ai.generativelanguage.v1beta.CacheService.DeleteCachedContentCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CacheService.prototype.deleteCachedContent = function deleteCachedContent(request, callback) { + return this.rpcCall(deleteCachedContent, $root.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteCachedContent" }); + + /** + * Calls DeleteCachedContent. + * @function deleteCachedContent + * @memberof google.ai.generativelanguage.v1beta.CacheService + * @instance + * @param {google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest} request DeleteCachedContentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return CacheService; + })(); + + v1beta.ListCachedContentsRequest = (function() { + + /** + * Properties of a ListCachedContentsRequest. * @memberof google.ai.generativelanguage.v1beta - * @classdesc Represents a CitationMetadata. - * @implements ICitationMetadata + * @interface IListCachedContentsRequest + * @property {number|null} [pageSize] ListCachedContentsRequest pageSize + * @property {string|null} [pageToken] ListCachedContentsRequest pageToken + */ + + /** + * Constructs a new ListCachedContentsRequest. + * @memberof google.ai.generativelanguage.v1beta + * @classdesc Represents a ListCachedContentsRequest. + * @implements IListCachedContentsRequest * @constructor - * @param {google.ai.generativelanguage.v1beta.ICitationMetadata=} [properties] Properties to set + * @param {google.ai.generativelanguage.v1beta.IListCachedContentsRequest=} [properties] Properties to set */ - function CitationMetadata(properties) { - this.citationSources = []; + function ListCachedContentsRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -7444,78 +7644,89 @@ } /** - * CitationMetadata citationSources. - * @member {Array.} citationSources - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * ListCachedContentsRequest pageSize. + * @member {number} pageSize + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @instance */ - CitationMetadata.prototype.citationSources = $util.emptyArray; + ListCachedContentsRequest.prototype.pageSize = 0; /** - * Creates a new CitationMetadata instance using the specified properties. + * ListCachedContentsRequest pageToken. + * @member {string} pageToken + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest + * @instance + */ + ListCachedContentsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListCachedContentsRequest instance using the specified properties. * @function create - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @static - * @param {google.ai.generativelanguage.v1beta.ICitationMetadata=} [properties] Properties to set - * @returns {google.ai.generativelanguage.v1beta.CitationMetadata} CitationMetadata instance + * @param {google.ai.generativelanguage.v1beta.IListCachedContentsRequest=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.ListCachedContentsRequest} ListCachedContentsRequest instance */ - CitationMetadata.create = function create(properties) { - return new CitationMetadata(properties); + ListCachedContentsRequest.create = function create(properties) { + return new ListCachedContentsRequest(properties); }; /** - * Encodes the specified CitationMetadata message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationMetadata.verify|verify} messages. + * Encodes the specified ListCachedContentsRequest message. Does not implicitly {@link google.ai.generativelanguage.v1beta.ListCachedContentsRequest.verify|verify} messages. * @function encode - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @static - * @param {google.ai.generativelanguage.v1beta.ICitationMetadata} message CitationMetadata message or plain object to encode + * @param {google.ai.generativelanguage.v1beta.IListCachedContentsRequest} message ListCachedContentsRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - CitationMetadata.encode = function encode(message, writer) { + ListCachedContentsRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.citationSources != null && message.citationSources.length) - for (var i = 0; i < message.citationSources.length; ++i) - $root.google.ai.generativelanguage.v1beta.CitationSource.encode(message.citationSources[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.pageToken); return writer; }; /** - * Encodes the specified CitationMetadata message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationMetadata.verify|verify} messages. + * Encodes the specified ListCachedContentsRequest message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.ListCachedContentsRequest.verify|verify} messages. * @function encodeDelimited - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @static - * @param {google.ai.generativelanguage.v1beta.ICitationMetadata} message CitationMetadata message or plain object to encode + * @param {google.ai.generativelanguage.v1beta.IListCachedContentsRequest} message ListCachedContentsRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - CitationMetadata.encodeDelimited = function encodeDelimited(message, writer) { + ListCachedContentsRequest.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a CitationMetadata message from the specified reader or buffer. + * Decodes a ListCachedContentsRequest message from the specified reader or buffer. * @function decode - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.ai.generativelanguage.v1beta.CitationMetadata} CitationMetadata + * @returns {google.ai.generativelanguage.v1beta.ListCachedContentsRequest} ListCachedContentsRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - CitationMetadata.decode = function decode(reader, length) { + ListCachedContentsRequest.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.ai.generativelanguage.v1beta.CitationMetadata(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.ai.generativelanguage.v1beta.ListCachedContentsRequest(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - if (!(message.citationSources && message.citationSources.length)) - message.citationSources = []; - message.citationSources.push($root.google.ai.generativelanguage.v1beta.CitationSource.decode(reader, reader.uint32())); + message.pageSize = reader.int32(); + break; + } + case 2: { + message.pageToken = reader.string(); break; } default: @@ -7527,142 +7738,133 @@ }; /** - * Decodes a CitationMetadata message from the specified reader or buffer, length delimited. + * Decodes a ListCachedContentsRequest message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.ai.generativelanguage.v1beta.CitationMetadata} CitationMetadata + * @returns {google.ai.generativelanguage.v1beta.ListCachedContentsRequest} ListCachedContentsRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - CitationMetadata.decodeDelimited = function decodeDelimited(reader) { + ListCachedContentsRequest.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a CitationMetadata message. + * Verifies a ListCachedContentsRequest message. * @function verify - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - CitationMetadata.verify = function verify(message) { + ListCachedContentsRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.citationSources != null && message.hasOwnProperty("citationSources")) { - if (!Array.isArray(message.citationSources)) - return "citationSources: array expected"; - for (var i = 0; i < message.citationSources.length; ++i) { - var error = $root.google.ai.generativelanguage.v1beta.CitationSource.verify(message.citationSources[i]); - if (error) - return "citationSources." + error; - } - } + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; return null; }; /** - * Creates a CitationMetadata message from a plain object. Also converts values to their respective internal types. + * Creates a ListCachedContentsRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @static * @param {Object.} object Plain object - * @returns {google.ai.generativelanguage.v1beta.CitationMetadata} CitationMetadata + * @returns {google.ai.generativelanguage.v1beta.ListCachedContentsRequest} ListCachedContentsRequest */ - CitationMetadata.fromObject = function fromObject(object) { - if (object instanceof $root.google.ai.generativelanguage.v1beta.CitationMetadata) + ListCachedContentsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.ListCachedContentsRequest) return object; - var message = new $root.google.ai.generativelanguage.v1beta.CitationMetadata(); - if (object.citationSources) { - if (!Array.isArray(object.citationSources)) - throw TypeError(".google.ai.generativelanguage.v1beta.CitationMetadata.citationSources: array expected"); - message.citationSources = []; - for (var i = 0; i < object.citationSources.length; ++i) { - if (typeof object.citationSources[i] !== "object") - throw TypeError(".google.ai.generativelanguage.v1beta.CitationMetadata.citationSources: object expected"); - message.citationSources[i] = $root.google.ai.generativelanguage.v1beta.CitationSource.fromObject(object.citationSources[i]); - } - } + var message = new $root.google.ai.generativelanguage.v1beta.ListCachedContentsRequest(); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); return message; }; /** - * Creates a plain object from a CitationMetadata message. Also converts values to other types if specified. + * Creates a plain object from a ListCachedContentsRequest message. Also converts values to other types if specified. * @function toObject - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @static - * @param {google.ai.generativelanguage.v1beta.CitationMetadata} message CitationMetadata + * @param {google.ai.generativelanguage.v1beta.ListCachedContentsRequest} message ListCachedContentsRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - CitationMetadata.toObject = function toObject(message, options) { + ListCachedContentsRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) - object.citationSources = []; - if (message.citationSources && message.citationSources.length) { - object.citationSources = []; - for (var j = 0; j < message.citationSources.length; ++j) - object.citationSources[j] = $root.google.ai.generativelanguage.v1beta.CitationSource.toObject(message.citationSources[j], options); + if (options.defaults) { + object.pageSize = 0; + object.pageToken = ""; } + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; return object; }; /** - * Converts this CitationMetadata to JSON. + * Converts this ListCachedContentsRequest to JSON. * @function toJSON - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @instance * @returns {Object.} JSON object */ - CitationMetadata.prototype.toJSON = function toJSON() { + ListCachedContentsRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for CitationMetadata + * Gets the default type url for ListCachedContentsRequest * @function getTypeUrl - * @memberof google.ai.generativelanguage.v1beta.CitationMetadata + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsRequest * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - CitationMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + ListCachedContentsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.CitationMetadata"; + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.ListCachedContentsRequest"; }; - return CitationMetadata; + return ListCachedContentsRequest; })(); - v1beta.CitationSource = (function() { + v1beta.ListCachedContentsResponse = (function() { /** - * Properties of a CitationSource. + * Properties of a ListCachedContentsResponse. * @memberof google.ai.generativelanguage.v1beta - * @interface ICitationSource - * @property {number|null} [startIndex] CitationSource startIndex - * @property {number|null} [endIndex] CitationSource endIndex - * @property {string|null} [uri] CitationSource uri - * @property {string|null} [license] CitationSource license + * @interface IListCachedContentsResponse + * @property {Array.|null} [cachedContents] ListCachedContentsResponse cachedContents + * @property {string|null} [nextPageToken] ListCachedContentsResponse nextPageToken */ /** - * Constructs a new CitationSource. + * Constructs a new ListCachedContentsResponse. * @memberof google.ai.generativelanguage.v1beta - * @classdesc Represents a CitationSource. - * @implements ICitationSource + * @classdesc Represents a ListCachedContentsResponse. + * @implements IListCachedContentsResponse * @constructor - * @param {google.ai.generativelanguage.v1beta.ICitationSource=} [properties] Properties to set + * @param {google.ai.generativelanguage.v1beta.IListCachedContentsResponse=} [properties] Properties to set */ - function CitationSource(properties) { + function ListCachedContentsResponse(properties) { + this.cachedContents = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -7670,164 +7872,92 @@ } /** - * CitationSource startIndex. - * @member {number|null|undefined} startIndex - * @memberof google.ai.generativelanguage.v1beta.CitationSource - * @instance - */ - CitationSource.prototype.startIndex = null; - - /** - * CitationSource endIndex. - * @member {number|null|undefined} endIndex - * @memberof google.ai.generativelanguage.v1beta.CitationSource - * @instance - */ - CitationSource.prototype.endIndex = null; - - /** - * CitationSource uri. - * @member {string|null|undefined} uri - * @memberof google.ai.generativelanguage.v1beta.CitationSource - * @instance - */ - CitationSource.prototype.uri = null; - - /** - * CitationSource license. - * @member {string|null|undefined} license - * @memberof google.ai.generativelanguage.v1beta.CitationSource - * @instance - */ - CitationSource.prototype.license = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * CitationSource _startIndex. - * @member {"startIndex"|undefined} _startIndex - * @memberof google.ai.generativelanguage.v1beta.CitationSource - * @instance - */ - Object.defineProperty(CitationSource.prototype, "_startIndex", { - get: $util.oneOfGetter($oneOfFields = ["startIndex"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * CitationSource _endIndex. - * @member {"endIndex"|undefined} _endIndex - * @memberof google.ai.generativelanguage.v1beta.CitationSource - * @instance - */ - Object.defineProperty(CitationSource.prototype, "_endIndex", { - get: $util.oneOfGetter($oneOfFields = ["endIndex"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * CitationSource _uri. - * @member {"uri"|undefined} _uri - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * ListCachedContentsResponse cachedContents. + * @member {Array.} cachedContents + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @instance */ - Object.defineProperty(CitationSource.prototype, "_uri", { - get: $util.oneOfGetter($oneOfFields = ["uri"]), - set: $util.oneOfSetter($oneOfFields) - }); + ListCachedContentsResponse.prototype.cachedContents = $util.emptyArray; /** - * CitationSource _license. - * @member {"license"|undefined} _license - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * ListCachedContentsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @instance */ - Object.defineProperty(CitationSource.prototype, "_license", { - get: $util.oneOfGetter($oneOfFields = ["license"]), - set: $util.oneOfSetter($oneOfFields) - }); + ListCachedContentsResponse.prototype.nextPageToken = ""; /** - * Creates a new CitationSource instance using the specified properties. + * Creates a new ListCachedContentsResponse instance using the specified properties. * @function create - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @static - * @param {google.ai.generativelanguage.v1beta.ICitationSource=} [properties] Properties to set - * @returns {google.ai.generativelanguage.v1beta.CitationSource} CitationSource instance + * @param {google.ai.generativelanguage.v1beta.IListCachedContentsResponse=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.ListCachedContentsResponse} ListCachedContentsResponse instance */ - CitationSource.create = function create(properties) { - return new CitationSource(properties); + ListCachedContentsResponse.create = function create(properties) { + return new ListCachedContentsResponse(properties); }; /** - * Encodes the specified CitationSource message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationSource.verify|verify} messages. + * Encodes the specified ListCachedContentsResponse message. Does not implicitly {@link google.ai.generativelanguage.v1beta.ListCachedContentsResponse.verify|verify} messages. * @function encode - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @static - * @param {google.ai.generativelanguage.v1beta.ICitationSource} message CitationSource message or plain object to encode + * @param {google.ai.generativelanguage.v1beta.IListCachedContentsResponse} message ListCachedContentsResponse message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - CitationSource.encode = function encode(message, writer) { + ListCachedContentsResponse.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.startIndex != null && Object.hasOwnProperty.call(message, "startIndex")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.startIndex); - if (message.endIndex != null && Object.hasOwnProperty.call(message, "endIndex")) - writer.uint32(/* id 2, wireType 0 =*/16).int32(message.endIndex); - if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.uri); - if (message.license != null && Object.hasOwnProperty.call(message, "license")) - writer.uint32(/* id 4, wireType 2 =*/34).string(message.license); + if (message.cachedContents != null && message.cachedContents.length) + for (var i = 0; i < message.cachedContents.length; ++i) + $root.google.ai.generativelanguage.v1beta.CachedContent.encode(message.cachedContents[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); return writer; }; /** - * Encodes the specified CitationSource message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationSource.verify|verify} messages. + * Encodes the specified ListCachedContentsResponse message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.ListCachedContentsResponse.verify|verify} messages. * @function encodeDelimited - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @static - * @param {google.ai.generativelanguage.v1beta.ICitationSource} message CitationSource message or plain object to encode + * @param {google.ai.generativelanguage.v1beta.IListCachedContentsResponse} message ListCachedContentsResponse message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - CitationSource.encodeDelimited = function encodeDelimited(message, writer) { + ListCachedContentsResponse.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a CitationSource message from the specified reader or buffer. + * Decodes a ListCachedContentsResponse message from the specified reader or buffer. * @function decode - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.ai.generativelanguage.v1beta.CitationSource} CitationSource + * @returns {google.ai.generativelanguage.v1beta.ListCachedContentsResponse} ListCachedContentsResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - CitationSource.decode = function decode(reader, length) { + ListCachedContentsResponse.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.ai.generativelanguage.v1beta.CitationSource(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.ai.generativelanguage.v1beta.ListCachedContentsResponse(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.startIndex = reader.int32(); + if (!(message.cachedContents && message.cachedContents.length)) + message.cachedContents = []; + message.cachedContents.push($root.google.ai.generativelanguage.v1beta.CachedContent.decode(reader, reader.uint32())); break; } case 2: { - message.endIndex = reader.int32(); - break; - } - case 3: { - message.uri = reader.string(); - break; - } - case 4: { - message.license = reader.string(); + message.nextPageToken = reader.string(); break; } default: @@ -7839,142 +7969,1822 @@ }; /** - * Decodes a CitationSource message from the specified reader or buffer, length delimited. + * Decodes a ListCachedContentsResponse message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.ai.generativelanguage.v1beta.CitationSource} CitationSource + * @returns {google.ai.generativelanguage.v1beta.ListCachedContentsResponse} ListCachedContentsResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - CitationSource.decodeDelimited = function decodeDelimited(reader) { + ListCachedContentsResponse.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a CitationSource message. + * Verifies a ListCachedContentsResponse message. * @function verify - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - CitationSource.verify = function verify(message) { + ListCachedContentsResponse.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - var properties = {}; - if (message.startIndex != null && message.hasOwnProperty("startIndex")) { - properties._startIndex = 1; - if (!$util.isInteger(message.startIndex)) - return "startIndex: integer expected"; - } - if (message.endIndex != null && message.hasOwnProperty("endIndex")) { - properties._endIndex = 1; - if (!$util.isInteger(message.endIndex)) - return "endIndex: integer expected"; - } - if (message.uri != null && message.hasOwnProperty("uri")) { - properties._uri = 1; - if (!$util.isString(message.uri)) - return "uri: string expected"; - } - if (message.license != null && message.hasOwnProperty("license")) { - properties._license = 1; - if (!$util.isString(message.license)) - return "license: string expected"; + if (message.cachedContents != null && message.hasOwnProperty("cachedContents")) { + if (!Array.isArray(message.cachedContents)) + return "cachedContents: array expected"; + for (var i = 0; i < message.cachedContents.length; ++i) { + var error = $root.google.ai.generativelanguage.v1beta.CachedContent.verify(message.cachedContents[i]); + if (error) + return "cachedContents." + error; + } } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; return null; }; /** - * Creates a CitationSource message from a plain object. Also converts values to their respective internal types. + * Creates a ListCachedContentsResponse message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @static * @param {Object.} object Plain object - * @returns {google.ai.generativelanguage.v1beta.CitationSource} CitationSource + * @returns {google.ai.generativelanguage.v1beta.ListCachedContentsResponse} ListCachedContentsResponse */ - CitationSource.fromObject = function fromObject(object) { - if (object instanceof $root.google.ai.generativelanguage.v1beta.CitationSource) + ListCachedContentsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.ListCachedContentsResponse) return object; - var message = new $root.google.ai.generativelanguage.v1beta.CitationSource(); - if (object.startIndex != null) - message.startIndex = object.startIndex | 0; - if (object.endIndex != null) - message.endIndex = object.endIndex | 0; - if (object.uri != null) - message.uri = String(object.uri); - if (object.license != null) - message.license = String(object.license); + var message = new $root.google.ai.generativelanguage.v1beta.ListCachedContentsResponse(); + if (object.cachedContents) { + if (!Array.isArray(object.cachedContents)) + throw TypeError(".google.ai.generativelanguage.v1beta.ListCachedContentsResponse.cachedContents: array expected"); + message.cachedContents = []; + for (var i = 0; i < object.cachedContents.length; ++i) { + if (typeof object.cachedContents[i] !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.ListCachedContentsResponse.cachedContents: object expected"); + message.cachedContents[i] = $root.google.ai.generativelanguage.v1beta.CachedContent.fromObject(object.cachedContents[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); return message; }; /** - * Creates a plain object from a CitationSource message. Also converts values to other types if specified. + * Creates a plain object from a ListCachedContentsResponse message. Also converts values to other types if specified. * @function toObject - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @static - * @param {google.ai.generativelanguage.v1beta.CitationSource} message CitationSource + * @param {google.ai.generativelanguage.v1beta.ListCachedContentsResponse} message ListCachedContentsResponse * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - CitationSource.toObject = function toObject(message, options) { + ListCachedContentsResponse.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (message.startIndex != null && message.hasOwnProperty("startIndex")) { - object.startIndex = message.startIndex; - if (options.oneofs) - object._startIndex = "startIndex"; - } - if (message.endIndex != null && message.hasOwnProperty("endIndex")) { - object.endIndex = message.endIndex; - if (options.oneofs) - object._endIndex = "endIndex"; - } - if (message.uri != null && message.hasOwnProperty("uri")) { - object.uri = message.uri; - if (options.oneofs) - object._uri = "uri"; - } - if (message.license != null && message.hasOwnProperty("license")) { - object.license = message.license; - if (options.oneofs) - object._license = "license"; + if (options.arrays || options.defaults) + object.cachedContents = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.cachedContents && message.cachedContents.length) { + object.cachedContents = []; + for (var j = 0; j < message.cachedContents.length; ++j) + object.cachedContents[j] = $root.google.ai.generativelanguage.v1beta.CachedContent.toObject(message.cachedContents[j], options); } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; return object; }; /** - * Converts this CitationSource to JSON. + * Converts this ListCachedContentsResponse to JSON. * @function toJSON - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @instance * @returns {Object.} JSON object */ - CitationSource.prototype.toJSON = function toJSON() { + ListCachedContentsResponse.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for CitationSource + * Gets the default type url for ListCachedContentsResponse * @function getTypeUrl - * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @memberof google.ai.generativelanguage.v1beta.ListCachedContentsResponse * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - CitationSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + ListCachedContentsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.CitationSource"; + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.ListCachedContentsResponse"; }; - return CitationSource; + return ListCachedContentsResponse; + })(); + + v1beta.CreateCachedContentRequest = (function() { + + /** + * Properties of a CreateCachedContentRequest. + * @memberof google.ai.generativelanguage.v1beta + * @interface ICreateCachedContentRequest + * @property {google.ai.generativelanguage.v1beta.ICachedContent|null} [cachedContent] CreateCachedContentRequest cachedContent + */ + + /** + * Constructs a new CreateCachedContentRequest. + * @memberof google.ai.generativelanguage.v1beta + * @classdesc Represents a CreateCachedContentRequest. + * @implements ICreateCachedContentRequest + * @constructor + * @param {google.ai.generativelanguage.v1beta.ICreateCachedContentRequest=} [properties] Properties to set + */ + function CreateCachedContentRequest(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]]; + } + + /** + * CreateCachedContentRequest cachedContent. + * @member {google.ai.generativelanguage.v1beta.ICachedContent|null|undefined} cachedContent + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @instance + */ + CreateCachedContentRequest.prototype.cachedContent = null; + + /** + * Creates a new CreateCachedContentRequest instance using the specified properties. + * @function create + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.ICreateCachedContentRequest=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.CreateCachedContentRequest} CreateCachedContentRequest instance + */ + CreateCachedContentRequest.create = function create(properties) { + return new CreateCachedContentRequest(properties); + }; + + /** + * Encodes the specified CreateCachedContentRequest message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CreateCachedContentRequest.verify|verify} messages. + * @function encode + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.ICreateCachedContentRequest} message CreateCachedContentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateCachedContentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.cachedContent != null && Object.hasOwnProperty.call(message, "cachedContent")) + $root.google.ai.generativelanguage.v1beta.CachedContent.encode(message.cachedContent, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CreateCachedContentRequest message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CreateCachedContentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.ICreateCachedContentRequest} message CreateCachedContentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateCachedContentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateCachedContentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.ai.generativelanguage.v1beta.CreateCachedContentRequest} CreateCachedContentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateCachedContentRequest.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.ai.generativelanguage.v1beta.CreateCachedContentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.cachedContent = $root.google.ai.generativelanguage.v1beta.CachedContent.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateCachedContentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.ai.generativelanguage.v1beta.CreateCachedContentRequest} CreateCachedContentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateCachedContentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateCachedContentRequest message. + * @function verify + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateCachedContentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.cachedContent != null && message.hasOwnProperty("cachedContent")) { + var error = $root.google.ai.generativelanguage.v1beta.CachedContent.verify(message.cachedContent); + if (error) + return "cachedContent." + error; + } + return null; + }; + + /** + * Creates a CreateCachedContentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.ai.generativelanguage.v1beta.CreateCachedContentRequest} CreateCachedContentRequest + */ + CreateCachedContentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.CreateCachedContentRequest) + return object; + var message = new $root.google.ai.generativelanguage.v1beta.CreateCachedContentRequest(); + if (object.cachedContent != null) { + if (typeof object.cachedContent !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CreateCachedContentRequest.cachedContent: object expected"); + message.cachedContent = $root.google.ai.generativelanguage.v1beta.CachedContent.fromObject(object.cachedContent); + } + return message; + }; + + /** + * Creates a plain object from a CreateCachedContentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.CreateCachedContentRequest} message CreateCachedContentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateCachedContentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.cachedContent = null; + if (message.cachedContent != null && message.hasOwnProperty("cachedContent")) + object.cachedContent = $root.google.ai.generativelanguage.v1beta.CachedContent.toObject(message.cachedContent, options); + return object; + }; + + /** + * Converts this CreateCachedContentRequest to JSON. + * @function toJSON + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @instance + * @returns {Object.} JSON object + */ + CreateCachedContentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateCachedContentRequest + * @function getTypeUrl + * @memberof google.ai.generativelanguage.v1beta.CreateCachedContentRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateCachedContentRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.CreateCachedContentRequest"; + }; + + return CreateCachedContentRequest; + })(); + + v1beta.GetCachedContentRequest = (function() { + + /** + * Properties of a GetCachedContentRequest. + * @memberof google.ai.generativelanguage.v1beta + * @interface IGetCachedContentRequest + * @property {string|null} [name] GetCachedContentRequest name + */ + + /** + * Constructs a new GetCachedContentRequest. + * @memberof google.ai.generativelanguage.v1beta + * @classdesc Represents a GetCachedContentRequest. + * @implements IGetCachedContentRequest + * @constructor + * @param {google.ai.generativelanguage.v1beta.IGetCachedContentRequest=} [properties] Properties to set + */ + function GetCachedContentRequest(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]]; + } + + /** + * GetCachedContentRequest name. + * @member {string} name + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @instance + */ + GetCachedContentRequest.prototype.name = ""; + + /** + * Creates a new GetCachedContentRequest instance using the specified properties. + * @function create + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.IGetCachedContentRequest=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.GetCachedContentRequest} GetCachedContentRequest instance + */ + GetCachedContentRequest.create = function create(properties) { + return new GetCachedContentRequest(properties); + }; + + /** + * Encodes the specified GetCachedContentRequest message. Does not implicitly {@link google.ai.generativelanguage.v1beta.GetCachedContentRequest.verify|verify} messages. + * @function encode + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.IGetCachedContentRequest} message GetCachedContentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCachedContentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified GetCachedContentRequest message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.GetCachedContentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.IGetCachedContentRequest} message GetCachedContentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCachedContentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetCachedContentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.ai.generativelanguage.v1beta.GetCachedContentRequest} GetCachedContentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCachedContentRequest.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.ai.generativelanguage.v1beta.GetCachedContentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetCachedContentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.ai.generativelanguage.v1beta.GetCachedContentRequest} GetCachedContentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCachedContentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetCachedContentRequest message. + * @function verify + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetCachedContentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a GetCachedContentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.ai.generativelanguage.v1beta.GetCachedContentRequest} GetCachedContentRequest + */ + GetCachedContentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.GetCachedContentRequest) + return object; + var message = new $root.google.ai.generativelanguage.v1beta.GetCachedContentRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetCachedContentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.GetCachedContentRequest} message GetCachedContentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetCachedContentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetCachedContentRequest to JSON. + * @function toJSON + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @instance + * @returns {Object.} JSON object + */ + GetCachedContentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetCachedContentRequest + * @function getTypeUrl + * @memberof google.ai.generativelanguage.v1beta.GetCachedContentRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetCachedContentRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.GetCachedContentRequest"; + }; + + return GetCachedContentRequest; + })(); + + v1beta.UpdateCachedContentRequest = (function() { + + /** + * Properties of an UpdateCachedContentRequest. + * @memberof google.ai.generativelanguage.v1beta + * @interface IUpdateCachedContentRequest + * @property {google.ai.generativelanguage.v1beta.ICachedContent|null} [cachedContent] UpdateCachedContentRequest cachedContent + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateCachedContentRequest updateMask + */ + + /** + * Constructs a new UpdateCachedContentRequest. + * @memberof google.ai.generativelanguage.v1beta + * @classdesc Represents an UpdateCachedContentRequest. + * @implements IUpdateCachedContentRequest + * @constructor + * @param {google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest=} [properties] Properties to set + */ + function UpdateCachedContentRequest(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]]; + } + + /** + * UpdateCachedContentRequest cachedContent. + * @member {google.ai.generativelanguage.v1beta.ICachedContent|null|undefined} cachedContent + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @instance + */ + UpdateCachedContentRequest.prototype.cachedContent = null; + + /** + * UpdateCachedContentRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @instance + */ + UpdateCachedContentRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateCachedContentRequest instance using the specified properties. + * @function create + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.UpdateCachedContentRequest} UpdateCachedContentRequest instance + */ + UpdateCachedContentRequest.create = function create(properties) { + return new UpdateCachedContentRequest(properties); + }; + + /** + * Encodes the specified UpdateCachedContentRequest message. Does not implicitly {@link google.ai.generativelanguage.v1beta.UpdateCachedContentRequest.verify|verify} messages. + * @function encode + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest} message UpdateCachedContentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCachedContentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.cachedContent != null && Object.hasOwnProperty.call(message, "cachedContent")) + $root.google.ai.generativelanguage.v1beta.CachedContent.encode(message.cachedContent, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateCachedContentRequest message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.UpdateCachedContentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest} message UpdateCachedContentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCachedContentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateCachedContentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.ai.generativelanguage.v1beta.UpdateCachedContentRequest} UpdateCachedContentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCachedContentRequest.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.ai.generativelanguage.v1beta.UpdateCachedContentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.cachedContent = $root.google.ai.generativelanguage.v1beta.CachedContent.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateCachedContentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.ai.generativelanguage.v1beta.UpdateCachedContentRequest} UpdateCachedContentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCachedContentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateCachedContentRequest message. + * @function verify + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateCachedContentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.cachedContent != null && message.hasOwnProperty("cachedContent")) { + var error = $root.google.ai.generativelanguage.v1beta.CachedContent.verify(message.cachedContent); + if (error) + return "cachedContent." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateCachedContentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.ai.generativelanguage.v1beta.UpdateCachedContentRequest} UpdateCachedContentRequest + */ + UpdateCachedContentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest) + return object; + var message = new $root.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest(); + if (object.cachedContent != null) { + if (typeof object.cachedContent !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.UpdateCachedContentRequest.cachedContent: object expected"); + message.cachedContent = $root.google.ai.generativelanguage.v1beta.CachedContent.fromObject(object.cachedContent); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.UpdateCachedContentRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateCachedContentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.UpdateCachedContentRequest} message UpdateCachedContentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateCachedContentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.cachedContent = null; + object.updateMask = null; + } + if (message.cachedContent != null && message.hasOwnProperty("cachedContent")) + object.cachedContent = $root.google.ai.generativelanguage.v1beta.CachedContent.toObject(message.cachedContent, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateCachedContentRequest to JSON. + * @function toJSON + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateCachedContentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateCachedContentRequest + * @function getTypeUrl + * @memberof google.ai.generativelanguage.v1beta.UpdateCachedContentRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateCachedContentRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.UpdateCachedContentRequest"; + }; + + return UpdateCachedContentRequest; + })(); + + v1beta.DeleteCachedContentRequest = (function() { + + /** + * Properties of a DeleteCachedContentRequest. + * @memberof google.ai.generativelanguage.v1beta + * @interface IDeleteCachedContentRequest + * @property {string|null} [name] DeleteCachedContentRequest name + */ + + /** + * Constructs a new DeleteCachedContentRequest. + * @memberof google.ai.generativelanguage.v1beta + * @classdesc Represents a DeleteCachedContentRequest. + * @implements IDeleteCachedContentRequest + * @constructor + * @param {google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest=} [properties] Properties to set + */ + function DeleteCachedContentRequest(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]]; + } + + /** + * DeleteCachedContentRequest name. + * @member {string} name + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @instance + */ + DeleteCachedContentRequest.prototype.name = ""; + + /** + * Creates a new DeleteCachedContentRequest instance using the specified properties. + * @function create + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.DeleteCachedContentRequest} DeleteCachedContentRequest instance + */ + DeleteCachedContentRequest.create = function create(properties) { + return new DeleteCachedContentRequest(properties); + }; + + /** + * Encodes the specified DeleteCachedContentRequest message. Does not implicitly {@link google.ai.generativelanguage.v1beta.DeleteCachedContentRequest.verify|verify} messages. + * @function encode + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest} message DeleteCachedContentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteCachedContentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified DeleteCachedContentRequest message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.DeleteCachedContentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest} message DeleteCachedContentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteCachedContentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteCachedContentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.ai.generativelanguage.v1beta.DeleteCachedContentRequest} DeleteCachedContentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteCachedContentRequest.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.ai.generativelanguage.v1beta.DeleteCachedContentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteCachedContentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.ai.generativelanguage.v1beta.DeleteCachedContentRequest} DeleteCachedContentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteCachedContentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteCachedContentRequest message. + * @function verify + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteCachedContentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a DeleteCachedContentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.ai.generativelanguage.v1beta.DeleteCachedContentRequest} DeleteCachedContentRequest + */ + DeleteCachedContentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest) + return object; + var message = new $root.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteCachedContentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @static + * @param {google.ai.generativelanguage.v1beta.DeleteCachedContentRequest} message DeleteCachedContentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteCachedContentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this DeleteCachedContentRequest to JSON. + * @function toJSON + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteCachedContentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteCachedContentRequest + * @function getTypeUrl + * @memberof google.ai.generativelanguage.v1beta.DeleteCachedContentRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteCachedContentRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.DeleteCachedContentRequest"; + }; + + return DeleteCachedContentRequest; + })(); + + v1beta.CachedContent = (function() { + + /** + * Properties of a CachedContent. + * @memberof google.ai.generativelanguage.v1beta + * @interface ICachedContent + * @property {google.protobuf.ITimestamp|null} [expireTime] CachedContent expireTime + * @property {google.protobuf.IDuration|null} [ttl] CachedContent ttl + * @property {string|null} [name] CachedContent name + * @property {string|null} [displayName] CachedContent displayName + * @property {string|null} [model] CachedContent model + * @property {google.ai.generativelanguage.v1beta.IContent|null} [systemInstruction] CachedContent systemInstruction + * @property {Array.|null} [contents] CachedContent contents + * @property {Array.|null} [tools] CachedContent tools + * @property {google.ai.generativelanguage.v1beta.IToolConfig|null} [toolConfig] CachedContent toolConfig + * @property {google.protobuf.ITimestamp|null} [createTime] CachedContent createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] CachedContent updateTime + * @property {google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata|null} [usageMetadata] CachedContent usageMetadata + */ + + /** + * Constructs a new CachedContent. + * @memberof google.ai.generativelanguage.v1beta + * @classdesc Represents a CachedContent. + * @implements ICachedContent + * @constructor + * @param {google.ai.generativelanguage.v1beta.ICachedContent=} [properties] Properties to set + */ + function CachedContent(properties) { + this.contents = []; + this.tools = []; + 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]]; + } + + /** + * CachedContent expireTime. + * @member {google.protobuf.ITimestamp|null|undefined} expireTime + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.expireTime = null; + + /** + * CachedContent ttl. + * @member {google.protobuf.IDuration|null|undefined} ttl + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.ttl = null; + + /** + * CachedContent name. + * @member {string|null|undefined} name + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.name = null; + + /** + * CachedContent displayName. + * @member {string|null|undefined} displayName + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.displayName = null; + + /** + * CachedContent model. + * @member {string|null|undefined} model + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.model = null; + + /** + * CachedContent systemInstruction. + * @member {google.ai.generativelanguage.v1beta.IContent|null|undefined} systemInstruction + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.systemInstruction = null; + + /** + * CachedContent contents. + * @member {Array.} contents + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.contents = $util.emptyArray; + + /** + * CachedContent tools. + * @member {Array.} tools + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.tools = $util.emptyArray; + + /** + * CachedContent toolConfig. + * @member {google.ai.generativelanguage.v1beta.IToolConfig|null|undefined} toolConfig + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.toolConfig = null; + + /** + * CachedContent createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.createTime = null; + + /** + * CachedContent updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.updateTime = null; + + /** + * CachedContent usageMetadata. + * @member {google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata|null|undefined} usageMetadata + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + CachedContent.prototype.usageMetadata = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * CachedContent expiration. + * @member {"expireTime"|"ttl"|undefined} expiration + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + Object.defineProperty(CachedContent.prototype, "expiration", { + get: $util.oneOfGetter($oneOfFields = ["expireTime", "ttl"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CachedContent _name. + * @member {"name"|undefined} _name + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + Object.defineProperty(CachedContent.prototype, "_name", { + get: $util.oneOfGetter($oneOfFields = ["name"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CachedContent _displayName. + * @member {"displayName"|undefined} _displayName + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + Object.defineProperty(CachedContent.prototype, "_displayName", { + get: $util.oneOfGetter($oneOfFields = ["displayName"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CachedContent _model. + * @member {"model"|undefined} _model + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + Object.defineProperty(CachedContent.prototype, "_model", { + get: $util.oneOfGetter($oneOfFields = ["model"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CachedContent _systemInstruction. + * @member {"systemInstruction"|undefined} _systemInstruction + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + Object.defineProperty(CachedContent.prototype, "_systemInstruction", { + get: $util.oneOfGetter($oneOfFields = ["systemInstruction"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CachedContent _toolConfig. + * @member {"toolConfig"|undefined} _toolConfig + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + */ + Object.defineProperty(CachedContent.prototype, "_toolConfig", { + get: $util.oneOfGetter($oneOfFields = ["toolConfig"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new CachedContent instance using the specified properties. + * @function create + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @static + * @param {google.ai.generativelanguage.v1beta.ICachedContent=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.CachedContent} CachedContent instance + */ + CachedContent.create = function create(properties) { + return new CachedContent(properties); + }; + + /** + * Encodes the specified CachedContent message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CachedContent.verify|verify} messages. + * @function encode + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @static + * @param {google.ai.generativelanguage.v1beta.ICachedContent} message CachedContent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CachedContent.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.model); + if (message.systemInstruction != null && Object.hasOwnProperty.call(message, "systemInstruction")) + $root.google.ai.generativelanguage.v1beta.Content.encode(message.systemInstruction, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.contents != null && message.contents.length) + for (var i = 0; i < message.contents.length; ++i) + $root.google.ai.generativelanguage.v1beta.Content.encode(message.contents[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.tools != null && message.tools.length) + for (var i = 0; i < message.tools.length; ++i) + $root.google.ai.generativelanguage.v1beta.Tool.encode(message.tools[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.toolConfig != null && Object.hasOwnProperty.call(message, "toolConfig")) + $root.google.ai.generativelanguage.v1beta.ToolConfig.encode(message.toolConfig, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.expireTime != null && Object.hasOwnProperty.call(message, "expireTime")) + $root.google.protobuf.Timestamp.encode(message.expireTime, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.ttl != null && Object.hasOwnProperty.call(message, "ttl")) + $root.google.protobuf.Duration.encode(message.ttl, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.displayName); + if (message.usageMetadata != null && Object.hasOwnProperty.call(message, "usageMetadata")) + $root.google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata.encode(message.usageMetadata, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CachedContent message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CachedContent.verify|verify} messages. + * @function encodeDelimited + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @static + * @param {google.ai.generativelanguage.v1beta.ICachedContent} message CachedContent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CachedContent.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CachedContent message from the specified reader or buffer. + * @function decode + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.ai.generativelanguage.v1beta.CachedContent} CachedContent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CachedContent.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.ai.generativelanguage.v1beta.CachedContent(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 9: { + message.expireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 10: { + message.ttl = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 1: { + message.name = reader.string(); + break; + } + case 11: { + message.displayName = reader.string(); + break; + } + case 2: { + message.model = reader.string(); + break; + } + case 3: { + message.systemInstruction = $root.google.ai.generativelanguage.v1beta.Content.decode(reader, reader.uint32()); + break; + } + case 4: { + if (!(message.contents && message.contents.length)) + message.contents = []; + message.contents.push($root.google.ai.generativelanguage.v1beta.Content.decode(reader, reader.uint32())); + break; + } + case 5: { + if (!(message.tools && message.tools.length)) + message.tools = []; + message.tools.push($root.google.ai.generativelanguage.v1beta.Tool.decode(reader, reader.uint32())); + break; + } + case 6: { + message.toolConfig = $root.google.ai.generativelanguage.v1beta.ToolConfig.decode(reader, reader.uint32()); + break; + } + case 7: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 8: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 12: { + message.usageMetadata = $root.google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CachedContent message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.ai.generativelanguage.v1beta.CachedContent} CachedContent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CachedContent.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CachedContent message. + * @function verify + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CachedContent.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + properties.expiration = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.expireTime); + if (error) + return "expireTime." + error; + } + } + if (message.ttl != null && message.hasOwnProperty("ttl")) { + if (properties.expiration === 1) + return "expiration: multiple values"; + properties.expiration = 1; + { + var error = $root.google.protobuf.Duration.verify(message.ttl); + if (error) + return "ttl." + error; + } + } + if (message.name != null && message.hasOwnProperty("name")) { + properties._name = 1; + if (!$util.isString(message.name)) + return "name: string expected"; + } + if (message.displayName != null && message.hasOwnProperty("displayName")) { + properties._displayName = 1; + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + } + if (message.model != null && message.hasOwnProperty("model")) { + properties._model = 1; + if (!$util.isString(message.model)) + return "model: string expected"; + } + if (message.systemInstruction != null && message.hasOwnProperty("systemInstruction")) { + properties._systemInstruction = 1; + { + var error = $root.google.ai.generativelanguage.v1beta.Content.verify(message.systemInstruction); + if (error) + return "systemInstruction." + error; + } + } + if (message.contents != null && message.hasOwnProperty("contents")) { + if (!Array.isArray(message.contents)) + return "contents: array expected"; + for (var i = 0; i < message.contents.length; ++i) { + var error = $root.google.ai.generativelanguage.v1beta.Content.verify(message.contents[i]); + if (error) + return "contents." + error; + } + } + if (message.tools != null && message.hasOwnProperty("tools")) { + if (!Array.isArray(message.tools)) + return "tools: array expected"; + for (var i = 0; i < message.tools.length; ++i) { + var error = $root.google.ai.generativelanguage.v1beta.Tool.verify(message.tools[i]); + if (error) + return "tools." + error; + } + } + if (message.toolConfig != null && message.hasOwnProperty("toolConfig")) { + properties._toolConfig = 1; + { + var error = $root.google.ai.generativelanguage.v1beta.ToolConfig.verify(message.toolConfig); + if (error) + return "toolConfig." + error; + } + } + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + if (message.usageMetadata != null && message.hasOwnProperty("usageMetadata")) { + var error = $root.google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata.verify(message.usageMetadata); + if (error) + return "usageMetadata." + error; + } + return null; + }; + + /** + * Creates a CachedContent message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @static + * @param {Object.} object Plain object + * @returns {google.ai.generativelanguage.v1beta.CachedContent} CachedContent + */ + CachedContent.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.CachedContent) + return object; + var message = new $root.google.ai.generativelanguage.v1beta.CachedContent(); + if (object.expireTime != null) { + if (typeof object.expireTime !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.expireTime: object expected"); + message.expireTime = $root.google.protobuf.Timestamp.fromObject(object.expireTime); + } + if (object.ttl != null) { + if (typeof object.ttl !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.ttl: object expected"); + message.ttl = $root.google.protobuf.Duration.fromObject(object.ttl); + } + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.model != null) + message.model = String(object.model); + if (object.systemInstruction != null) { + if (typeof object.systemInstruction !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.systemInstruction: object expected"); + message.systemInstruction = $root.google.ai.generativelanguage.v1beta.Content.fromObject(object.systemInstruction); + } + if (object.contents) { + if (!Array.isArray(object.contents)) + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.contents: array expected"); + message.contents = []; + for (var i = 0; i < object.contents.length; ++i) { + if (typeof object.contents[i] !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.contents: object expected"); + message.contents[i] = $root.google.ai.generativelanguage.v1beta.Content.fromObject(object.contents[i]); + } + } + if (object.tools) { + if (!Array.isArray(object.tools)) + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.tools: array expected"); + message.tools = []; + for (var i = 0; i < object.tools.length; ++i) { + if (typeof object.tools[i] !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.tools: object expected"); + message.tools[i] = $root.google.ai.generativelanguage.v1beta.Tool.fromObject(object.tools[i]); + } + } + if (object.toolConfig != null) { + if (typeof object.toolConfig !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.toolConfig: object expected"); + message.toolConfig = $root.google.ai.generativelanguage.v1beta.ToolConfig.fromObject(object.toolConfig); + } + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.usageMetadata != null) { + if (typeof object.usageMetadata !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CachedContent.usageMetadata: object expected"); + message.usageMetadata = $root.google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata.fromObject(object.usageMetadata); + } + return message; + }; + + /** + * Creates a plain object from a CachedContent message. Also converts values to other types if specified. + * @function toObject + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @static + * @param {google.ai.generativelanguage.v1beta.CachedContent} message CachedContent + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CachedContent.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.contents = []; + object.tools = []; + } + if (options.defaults) { + object.createTime = null; + object.updateTime = null; + object.usageMetadata = null; + } + if (message.name != null && message.hasOwnProperty("name")) { + object.name = message.name; + if (options.oneofs) + object._name = "name"; + } + if (message.model != null && message.hasOwnProperty("model")) { + object.model = message.model; + if (options.oneofs) + object._model = "model"; + } + if (message.systemInstruction != null && message.hasOwnProperty("systemInstruction")) { + object.systemInstruction = $root.google.ai.generativelanguage.v1beta.Content.toObject(message.systemInstruction, options); + if (options.oneofs) + object._systemInstruction = "systemInstruction"; + } + if (message.contents && message.contents.length) { + object.contents = []; + for (var j = 0; j < message.contents.length; ++j) + object.contents[j] = $root.google.ai.generativelanguage.v1beta.Content.toObject(message.contents[j], options); + } + if (message.tools && message.tools.length) { + object.tools = []; + for (var j = 0; j < message.tools.length; ++j) + object.tools[j] = $root.google.ai.generativelanguage.v1beta.Tool.toObject(message.tools[j], options); + } + if (message.toolConfig != null && message.hasOwnProperty("toolConfig")) { + object.toolConfig = $root.google.ai.generativelanguage.v1beta.ToolConfig.toObject(message.toolConfig, options); + if (options.oneofs) + object._toolConfig = "toolConfig"; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + object.expireTime = $root.google.protobuf.Timestamp.toObject(message.expireTime, options); + if (options.oneofs) + object.expiration = "expireTime"; + } + if (message.ttl != null && message.hasOwnProperty("ttl")) { + object.ttl = $root.google.protobuf.Duration.toObject(message.ttl, options); + if (options.oneofs) + object.expiration = "ttl"; + } + if (message.displayName != null && message.hasOwnProperty("displayName")) { + object.displayName = message.displayName; + if (options.oneofs) + object._displayName = "displayName"; + } + if (message.usageMetadata != null && message.hasOwnProperty("usageMetadata")) + object.usageMetadata = $root.google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata.toObject(message.usageMetadata, options); + return object; + }; + + /** + * Converts this CachedContent to JSON. + * @function toJSON + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @instance + * @returns {Object.} JSON object + */ + CachedContent.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CachedContent + * @function getTypeUrl + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CachedContent.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.CachedContent"; + }; + + CachedContent.UsageMetadata = (function() { + + /** + * Properties of a UsageMetadata. + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @interface IUsageMetadata + * @property {number|null} [totalTokenCount] UsageMetadata totalTokenCount + */ + + /** + * Constructs a new UsageMetadata. + * @memberof google.ai.generativelanguage.v1beta.CachedContent + * @classdesc Represents a UsageMetadata. + * @implements IUsageMetadata + * @constructor + * @param {google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata=} [properties] Properties to set + */ + function UsageMetadata(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]]; + } + + /** + * UsageMetadata totalTokenCount. + * @member {number} totalTokenCount + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @instance + */ + UsageMetadata.prototype.totalTokenCount = 0; + + /** + * Creates a new UsageMetadata instance using the specified properties. + * @function create + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @static + * @param {google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata} UsageMetadata instance + */ + UsageMetadata.create = function create(properties) { + return new UsageMetadata(properties); + }; + + /** + * Encodes the specified UsageMetadata message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata.verify|verify} messages. + * @function encode + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @static + * @param {google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata} message UsageMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UsageMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.totalTokenCount != null && Object.hasOwnProperty.call(message, "totalTokenCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.totalTokenCount); + return writer; + }; + + /** + * Encodes the specified UsageMetadata message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @static + * @param {google.ai.generativelanguage.v1beta.CachedContent.IUsageMetadata} message UsageMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UsageMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UsageMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata} UsageMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UsageMetadata.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.ai.generativelanguage.v1beta.CachedContent.UsageMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.totalTokenCount = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UsageMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata} UsageMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UsageMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UsageMetadata message. + * @function verify + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UsageMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.totalTokenCount != null && message.hasOwnProperty("totalTokenCount")) + if (!$util.isInteger(message.totalTokenCount)) + return "totalTokenCount: integer expected"; + return null; + }; + + /** + * Creates a UsageMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata} UsageMetadata + */ + UsageMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata) + return object; + var message = new $root.google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata(); + if (object.totalTokenCount != null) + message.totalTokenCount = object.totalTokenCount | 0; + return message; + }; + + /** + * Creates a plain object from a UsageMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @static + * @param {google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata} message UsageMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UsageMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.totalTokenCount = 0; + if (message.totalTokenCount != null && message.hasOwnProperty("totalTokenCount")) + object.totalTokenCount = message.totalTokenCount; + return object; + }; + + /** + * Converts this UsageMetadata to JSON. + * @function toJSON + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @instance + * @returns {Object.} JSON object + */ + UsageMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UsageMetadata + * @function getTypeUrl + * @memberof google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UsageMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.CachedContent.UsageMetadata"; + }; + + return UsageMetadata; + })(); + + return CachedContent; })(); /** @@ -11054,35 +12864,491 @@ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Schema.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + Schema.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.Schema"; + }; + + return Schema; + })(); + + v1beta.GroundingPassage = (function() { + + /** + * Properties of a GroundingPassage. + * @memberof google.ai.generativelanguage.v1beta + * @interface IGroundingPassage + * @property {string|null} [id] GroundingPassage id + * @property {google.ai.generativelanguage.v1beta.IContent|null} [content] GroundingPassage content + */ + + /** + * Constructs a new GroundingPassage. + * @memberof google.ai.generativelanguage.v1beta + * @classdesc Represents a GroundingPassage. + * @implements IGroundingPassage + * @constructor + * @param {google.ai.generativelanguage.v1beta.IGroundingPassage=} [properties] Properties to set + */ + function GroundingPassage(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]]; + } + + /** + * GroundingPassage id. + * @member {string} id + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @instance + */ + GroundingPassage.prototype.id = ""; + + /** + * GroundingPassage content. + * @member {google.ai.generativelanguage.v1beta.IContent|null|undefined} content + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @instance + */ + GroundingPassage.prototype.content = null; + + /** + * Creates a new GroundingPassage instance using the specified properties. + * @function create + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @static + * @param {google.ai.generativelanguage.v1beta.IGroundingPassage=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.GroundingPassage} GroundingPassage instance + */ + GroundingPassage.create = function create(properties) { + return new GroundingPassage(properties); + }; + + /** + * Encodes the specified GroundingPassage message. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassage.verify|verify} messages. + * @function encode + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @static + * @param {google.ai.generativelanguage.v1beta.IGroundingPassage} message GroundingPassage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GroundingPassage.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.content != null && Object.hasOwnProperty.call(message, "content")) + $root.google.ai.generativelanguage.v1beta.Content.encode(message.content, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GroundingPassage message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassage.verify|verify} messages. + * @function encodeDelimited + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @static + * @param {google.ai.generativelanguage.v1beta.IGroundingPassage} message GroundingPassage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GroundingPassage.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GroundingPassage message from the specified reader or buffer. + * @function decode + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.ai.generativelanguage.v1beta.GroundingPassage} GroundingPassage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GroundingPassage.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.ai.generativelanguage.v1beta.GroundingPassage(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.string(); + break; + } + case 2: { + message.content = $root.google.ai.generativelanguage.v1beta.Content.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GroundingPassage message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.ai.generativelanguage.v1beta.GroundingPassage} GroundingPassage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GroundingPassage.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GroundingPassage message. + * @function verify + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GroundingPassage.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.content != null && message.hasOwnProperty("content")) { + var error = $root.google.ai.generativelanguage.v1beta.Content.verify(message.content); + if (error) + return "content." + error; + } + return null; + }; + + /** + * Creates a GroundingPassage message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @static + * @param {Object.} object Plain object + * @returns {google.ai.generativelanguage.v1beta.GroundingPassage} GroundingPassage + */ + GroundingPassage.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.GroundingPassage) + return object; + var message = new $root.google.ai.generativelanguage.v1beta.GroundingPassage(); + if (object.id != null) + message.id = String(object.id); + if (object.content != null) { + if (typeof object.content !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.GroundingPassage.content: object expected"); + message.content = $root.google.ai.generativelanguage.v1beta.Content.fromObject(object.content); + } + return message; + }; + + /** + * Creates a plain object from a GroundingPassage message. Also converts values to other types if specified. + * @function toObject + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @static + * @param {google.ai.generativelanguage.v1beta.GroundingPassage} message GroundingPassage + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GroundingPassage.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = ""; + object.content = null; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.content != null && message.hasOwnProperty("content")) + object.content = $root.google.ai.generativelanguage.v1beta.Content.toObject(message.content, options); + return object; + }; + + /** + * Converts this GroundingPassage to JSON. + * @function toJSON + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @instance + * @returns {Object.} JSON object + */ + GroundingPassage.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GroundingPassage + * @function getTypeUrl + * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GroundingPassage.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.GroundingPassage"; + }; + + return GroundingPassage; + })(); + + v1beta.GroundingPassages = (function() { + + /** + * Properties of a GroundingPassages. + * @memberof google.ai.generativelanguage.v1beta + * @interface IGroundingPassages + * @property {Array.|null} [passages] GroundingPassages passages + */ + + /** + * Constructs a new GroundingPassages. + * @memberof google.ai.generativelanguage.v1beta + * @classdesc Represents a GroundingPassages. + * @implements IGroundingPassages + * @constructor + * @param {google.ai.generativelanguage.v1beta.IGroundingPassages=} [properties] Properties to set + */ + function GroundingPassages(properties) { + this.passages = []; + 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]]; + } + + /** + * GroundingPassages passages. + * @member {Array.} passages + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @instance + */ + GroundingPassages.prototype.passages = $util.emptyArray; + + /** + * Creates a new GroundingPassages instance using the specified properties. + * @function create + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @static + * @param {google.ai.generativelanguage.v1beta.IGroundingPassages=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.GroundingPassages} GroundingPassages instance + */ + GroundingPassages.create = function create(properties) { + return new GroundingPassages(properties); + }; + + /** + * Encodes the specified GroundingPassages message. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassages.verify|verify} messages. + * @function encode + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @static + * @param {google.ai.generativelanguage.v1beta.IGroundingPassages} message GroundingPassages message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GroundingPassages.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.passages != null && message.passages.length) + for (var i = 0; i < message.passages.length; ++i) + $root.google.ai.generativelanguage.v1beta.GroundingPassage.encode(message.passages[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GroundingPassages message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassages.verify|verify} messages. + * @function encodeDelimited + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @static + * @param {google.ai.generativelanguage.v1beta.IGroundingPassages} message GroundingPassages message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GroundingPassages.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GroundingPassages message from the specified reader or buffer. + * @function decode + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.ai.generativelanguage.v1beta.GroundingPassages} GroundingPassages + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GroundingPassages.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.ai.generativelanguage.v1beta.GroundingPassages(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.passages && message.passages.length)) + message.passages = []; + message.passages.push($root.google.ai.generativelanguage.v1beta.GroundingPassage.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GroundingPassages message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.ai.generativelanguage.v1beta.GroundingPassages} GroundingPassages + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GroundingPassages.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GroundingPassages message. + * @function verify + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GroundingPassages.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.passages != null && message.hasOwnProperty("passages")) { + if (!Array.isArray(message.passages)) + return "passages: array expected"; + for (var i = 0; i < message.passages.length; ++i) { + var error = $root.google.ai.generativelanguage.v1beta.GroundingPassage.verify(message.passages[i]); + if (error) + return "passages." + error; + } + } + return null; + }; + + /** + * Creates a GroundingPassages message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @static + * @param {Object.} object Plain object + * @returns {google.ai.generativelanguage.v1beta.GroundingPassages} GroundingPassages + */ + GroundingPassages.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.GroundingPassages) + return object; + var message = new $root.google.ai.generativelanguage.v1beta.GroundingPassages(); + if (object.passages) { + if (!Array.isArray(object.passages)) + throw TypeError(".google.ai.generativelanguage.v1beta.GroundingPassages.passages: array expected"); + message.passages = []; + for (var i = 0; i < object.passages.length; ++i) { + if (typeof object.passages[i] !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.GroundingPassages.passages: object expected"); + message.passages[i] = $root.google.ai.generativelanguage.v1beta.GroundingPassage.fromObject(object.passages[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a GroundingPassages message. Also converts values to other types if specified. + * @function toObject + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @static + * @param {google.ai.generativelanguage.v1beta.GroundingPassages} message GroundingPassages + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GroundingPassages.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.passages = []; + if (message.passages && message.passages.length) { + object.passages = []; + for (var j = 0; j < message.passages.length; ++j) + object.passages[j] = $root.google.ai.generativelanguage.v1beta.GroundingPassage.toObject(message.passages[j], options); + } + return object; + }; + + /** + * Converts this GroundingPassages to JSON. + * @function toJSON + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @instance + * @returns {Object.} JSON object + */ + GroundingPassages.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GroundingPassages + * @function getTypeUrl + * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GroundingPassages.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.Schema"; + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.GroundingPassages"; }; - return Schema; + return GroundingPassages; })(); - v1beta.GroundingPassage = (function() { + v1beta.CitationMetadata = (function() { /** - * Properties of a GroundingPassage. + * Properties of a CitationMetadata. * @memberof google.ai.generativelanguage.v1beta - * @interface IGroundingPassage - * @property {string|null} [id] GroundingPassage id - * @property {google.ai.generativelanguage.v1beta.IContent|null} [content] GroundingPassage content + * @interface ICitationMetadata + * @property {Array.|null} [citationSources] CitationMetadata citationSources */ /** - * Constructs a new GroundingPassage. + * Constructs a new CitationMetadata. * @memberof google.ai.generativelanguage.v1beta - * @classdesc Represents a GroundingPassage. - * @implements IGroundingPassage + * @classdesc Represents a CitationMetadata. + * @implements ICitationMetadata * @constructor - * @param {google.ai.generativelanguage.v1beta.IGroundingPassage=} [properties] Properties to set + * @param {google.ai.generativelanguage.v1beta.ICitationMetadata=} [properties] Properties to set */ - function GroundingPassage(properties) { + function CitationMetadata(properties) { + this.citationSources = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -11090,89 +13356,78 @@ } /** - * GroundingPassage id. - * @member {string} id - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage - * @instance - */ - GroundingPassage.prototype.id = ""; - - /** - * GroundingPassage content. - * @member {google.ai.generativelanguage.v1beta.IContent|null|undefined} content - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * CitationMetadata citationSources. + * @member {Array.} citationSources + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @instance */ - GroundingPassage.prototype.content = null; + CitationMetadata.prototype.citationSources = $util.emptyArray; /** - * Creates a new GroundingPassage instance using the specified properties. + * Creates a new CitationMetadata instance using the specified properties. * @function create - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @static - * @param {google.ai.generativelanguage.v1beta.IGroundingPassage=} [properties] Properties to set - * @returns {google.ai.generativelanguage.v1beta.GroundingPassage} GroundingPassage instance + * @param {google.ai.generativelanguage.v1beta.ICitationMetadata=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.CitationMetadata} CitationMetadata instance */ - GroundingPassage.create = function create(properties) { - return new GroundingPassage(properties); + CitationMetadata.create = function create(properties) { + return new CitationMetadata(properties); }; /** - * Encodes the specified GroundingPassage message. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassage.verify|verify} messages. + * Encodes the specified CitationMetadata message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationMetadata.verify|verify} messages. * @function encode - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @static - * @param {google.ai.generativelanguage.v1beta.IGroundingPassage} message GroundingPassage message or plain object to encode + * @param {google.ai.generativelanguage.v1beta.ICitationMetadata} message CitationMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - GroundingPassage.encode = function encode(message, writer) { + CitationMetadata.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.id != null && Object.hasOwnProperty.call(message, "id")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); - if (message.content != null && Object.hasOwnProperty.call(message, "content")) - $root.google.ai.generativelanguage.v1beta.Content.encode(message.content, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.citationSources != null && message.citationSources.length) + for (var i = 0; i < message.citationSources.length; ++i) + $root.google.ai.generativelanguage.v1beta.CitationSource.encode(message.citationSources[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); return writer; }; /** - * Encodes the specified GroundingPassage message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassage.verify|verify} messages. + * Encodes the specified CitationMetadata message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationMetadata.verify|verify} messages. * @function encodeDelimited - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @static - * @param {google.ai.generativelanguage.v1beta.IGroundingPassage} message GroundingPassage message or plain object to encode + * @param {google.ai.generativelanguage.v1beta.ICitationMetadata} message CitationMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - GroundingPassage.encodeDelimited = function encodeDelimited(message, writer) { + CitationMetadata.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a GroundingPassage message from the specified reader or buffer. + * Decodes a CitationMetadata message from the specified reader or buffer. * @function decode - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.ai.generativelanguage.v1beta.GroundingPassage} GroundingPassage + * @returns {google.ai.generativelanguage.v1beta.CitationMetadata} CitationMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - GroundingPassage.decode = function decode(reader, length) { + CitationMetadata.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.ai.generativelanguage.v1beta.GroundingPassage(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.ai.generativelanguage.v1beta.CitationMetadata(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.id = reader.string(); - break; - } - case 2: { - message.content = $root.google.ai.generativelanguage.v1beta.Content.decode(reader, reader.uint32()); + if (!(message.citationSources && message.citationSources.length)) + message.citationSources = []; + message.citationSources.push($root.google.ai.generativelanguage.v1beta.CitationSource.decode(reader, reader.uint32())); break; } default: @@ -11184,137 +13439,142 @@ }; /** - * Decodes a GroundingPassage message from the specified reader or buffer, length delimited. + * Decodes a CitationMetadata message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.ai.generativelanguage.v1beta.GroundingPassage} GroundingPassage + * @returns {google.ai.generativelanguage.v1beta.CitationMetadata} CitationMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - GroundingPassage.decodeDelimited = function decodeDelimited(reader) { + CitationMetadata.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a GroundingPassage message. + * Verifies a CitationMetadata message. * @function verify - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - GroundingPassage.verify = function verify(message) { + CitationMetadata.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.id != null && message.hasOwnProperty("id")) - if (!$util.isString(message.id)) - return "id: string expected"; - if (message.content != null && message.hasOwnProperty("content")) { - var error = $root.google.ai.generativelanguage.v1beta.Content.verify(message.content); - if (error) - return "content." + error; + if (message.citationSources != null && message.hasOwnProperty("citationSources")) { + if (!Array.isArray(message.citationSources)) + return "citationSources: array expected"; + for (var i = 0; i < message.citationSources.length; ++i) { + var error = $root.google.ai.generativelanguage.v1beta.CitationSource.verify(message.citationSources[i]); + if (error) + return "citationSources." + error; + } } return null; }; /** - * Creates a GroundingPassage message from a plain object. Also converts values to their respective internal types. + * Creates a CitationMetadata message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @static * @param {Object.} object Plain object - * @returns {google.ai.generativelanguage.v1beta.GroundingPassage} GroundingPassage + * @returns {google.ai.generativelanguage.v1beta.CitationMetadata} CitationMetadata */ - GroundingPassage.fromObject = function fromObject(object) { - if (object instanceof $root.google.ai.generativelanguage.v1beta.GroundingPassage) + CitationMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.CitationMetadata) return object; - var message = new $root.google.ai.generativelanguage.v1beta.GroundingPassage(); - if (object.id != null) - message.id = String(object.id); - if (object.content != null) { - if (typeof object.content !== "object") - throw TypeError(".google.ai.generativelanguage.v1beta.GroundingPassage.content: object expected"); - message.content = $root.google.ai.generativelanguage.v1beta.Content.fromObject(object.content); + var message = new $root.google.ai.generativelanguage.v1beta.CitationMetadata(); + if (object.citationSources) { + if (!Array.isArray(object.citationSources)) + throw TypeError(".google.ai.generativelanguage.v1beta.CitationMetadata.citationSources: array expected"); + message.citationSources = []; + for (var i = 0; i < object.citationSources.length; ++i) { + if (typeof object.citationSources[i] !== "object") + throw TypeError(".google.ai.generativelanguage.v1beta.CitationMetadata.citationSources: object expected"); + message.citationSources[i] = $root.google.ai.generativelanguage.v1beta.CitationSource.fromObject(object.citationSources[i]); + } } return message; }; /** - * Creates a plain object from a GroundingPassage message. Also converts values to other types if specified. + * Creates a plain object from a CitationMetadata message. Also converts values to other types if specified. * @function toObject - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @static - * @param {google.ai.generativelanguage.v1beta.GroundingPassage} message GroundingPassage + * @param {google.ai.generativelanguage.v1beta.CitationMetadata} message CitationMetadata * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - GroundingPassage.toObject = function toObject(message, options) { + CitationMetadata.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.defaults) { - object.id = ""; - object.content = null; + if (options.arrays || options.defaults) + object.citationSources = []; + if (message.citationSources && message.citationSources.length) { + object.citationSources = []; + for (var j = 0; j < message.citationSources.length; ++j) + object.citationSources[j] = $root.google.ai.generativelanguage.v1beta.CitationSource.toObject(message.citationSources[j], options); } - if (message.id != null && message.hasOwnProperty("id")) - object.id = message.id; - if (message.content != null && message.hasOwnProperty("content")) - object.content = $root.google.ai.generativelanguage.v1beta.Content.toObject(message.content, options); return object; }; /** - * Converts this GroundingPassage to JSON. + * Converts this CitationMetadata to JSON. * @function toJSON - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @instance * @returns {Object.} JSON object */ - GroundingPassage.prototype.toJSON = function toJSON() { + CitationMetadata.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for GroundingPassage + * Gets the default type url for CitationMetadata * @function getTypeUrl - * @memberof google.ai.generativelanguage.v1beta.GroundingPassage + * @memberof google.ai.generativelanguage.v1beta.CitationMetadata * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - GroundingPassage.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + CitationMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.GroundingPassage"; + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.CitationMetadata"; }; - return GroundingPassage; + return CitationMetadata; })(); - v1beta.GroundingPassages = (function() { + v1beta.CitationSource = (function() { /** - * Properties of a GroundingPassages. + * Properties of a CitationSource. * @memberof google.ai.generativelanguage.v1beta - * @interface IGroundingPassages - * @property {Array.|null} [passages] GroundingPassages passages + * @interface ICitationSource + * @property {number|null} [startIndex] CitationSource startIndex + * @property {number|null} [endIndex] CitationSource endIndex + * @property {string|null} [uri] CitationSource uri + * @property {string|null} [license] CitationSource license */ /** - * Constructs a new GroundingPassages. + * Constructs a new CitationSource. * @memberof google.ai.generativelanguage.v1beta - * @classdesc Represents a GroundingPassages. - * @implements IGroundingPassages + * @classdesc Represents a CitationSource. + * @implements ICitationSource * @constructor - * @param {google.ai.generativelanguage.v1beta.IGroundingPassages=} [properties] Properties to set + * @param {google.ai.generativelanguage.v1beta.ICitationSource=} [properties] Properties to set */ - function GroundingPassages(properties) { - this.passages = []; + function CitationSource(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -11322,78 +13582,164 @@ } /** - * GroundingPassages passages. - * @member {Array.} passages - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * CitationSource startIndex. + * @member {number|null|undefined} startIndex + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @instance */ - GroundingPassages.prototype.passages = $util.emptyArray; + CitationSource.prototype.startIndex = null; /** - * Creates a new GroundingPassages instance using the specified properties. + * CitationSource endIndex. + * @member {number|null|undefined} endIndex + * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @instance + */ + CitationSource.prototype.endIndex = null; + + /** + * CitationSource uri. + * @member {string|null|undefined} uri + * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @instance + */ + CitationSource.prototype.uri = null; + + /** + * CitationSource license. + * @member {string|null|undefined} license + * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @instance + */ + CitationSource.prototype.license = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * CitationSource _startIndex. + * @member {"startIndex"|undefined} _startIndex + * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @instance + */ + Object.defineProperty(CitationSource.prototype, "_startIndex", { + get: $util.oneOfGetter($oneOfFields = ["startIndex"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CitationSource _endIndex. + * @member {"endIndex"|undefined} _endIndex + * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @instance + */ + Object.defineProperty(CitationSource.prototype, "_endIndex", { + get: $util.oneOfGetter($oneOfFields = ["endIndex"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CitationSource _uri. + * @member {"uri"|undefined} _uri + * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @instance + */ + Object.defineProperty(CitationSource.prototype, "_uri", { + get: $util.oneOfGetter($oneOfFields = ["uri"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CitationSource _license. + * @member {"license"|undefined} _license + * @memberof google.ai.generativelanguage.v1beta.CitationSource + * @instance + */ + Object.defineProperty(CitationSource.prototype, "_license", { + get: $util.oneOfGetter($oneOfFields = ["license"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new CitationSource instance using the specified properties. * @function create - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @static - * @param {google.ai.generativelanguage.v1beta.IGroundingPassages=} [properties] Properties to set - * @returns {google.ai.generativelanguage.v1beta.GroundingPassages} GroundingPassages instance + * @param {google.ai.generativelanguage.v1beta.ICitationSource=} [properties] Properties to set + * @returns {google.ai.generativelanguage.v1beta.CitationSource} CitationSource instance */ - GroundingPassages.create = function create(properties) { - return new GroundingPassages(properties); + CitationSource.create = function create(properties) { + return new CitationSource(properties); }; /** - * Encodes the specified GroundingPassages message. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassages.verify|verify} messages. + * Encodes the specified CitationSource message. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationSource.verify|verify} messages. * @function encode - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @static - * @param {google.ai.generativelanguage.v1beta.IGroundingPassages} message GroundingPassages message or plain object to encode + * @param {google.ai.generativelanguage.v1beta.ICitationSource} message CitationSource message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - GroundingPassages.encode = function encode(message, writer) { + CitationSource.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.passages != null && message.passages.length) - for (var i = 0; i < message.passages.length; ++i) - $root.google.ai.generativelanguage.v1beta.GroundingPassage.encode(message.passages[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.startIndex != null && Object.hasOwnProperty.call(message, "startIndex")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.startIndex); + if (message.endIndex != null && Object.hasOwnProperty.call(message, "endIndex")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.endIndex); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.uri); + if (message.license != null && Object.hasOwnProperty.call(message, "license")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.license); return writer; }; /** - * Encodes the specified GroundingPassages message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.GroundingPassages.verify|verify} messages. + * Encodes the specified CitationSource message, length delimited. Does not implicitly {@link google.ai.generativelanguage.v1beta.CitationSource.verify|verify} messages. * @function encodeDelimited - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @static - * @param {google.ai.generativelanguage.v1beta.IGroundingPassages} message GroundingPassages message or plain object to encode + * @param {google.ai.generativelanguage.v1beta.ICitationSource} message CitationSource message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - GroundingPassages.encodeDelimited = function encodeDelimited(message, writer) { + CitationSource.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a GroundingPassages message from the specified reader or buffer. + * Decodes a CitationSource message from the specified reader or buffer. * @function decode - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.ai.generativelanguage.v1beta.GroundingPassages} GroundingPassages + * @returns {google.ai.generativelanguage.v1beta.CitationSource} CitationSource * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - GroundingPassages.decode = function decode(reader, length) { + CitationSource.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.ai.generativelanguage.v1beta.GroundingPassages(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.ai.generativelanguage.v1beta.CitationSource(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - if (!(message.passages && message.passages.length)) - message.passages = []; - message.passages.push($root.google.ai.generativelanguage.v1beta.GroundingPassage.decode(reader, reader.uint32())); + message.startIndex = reader.int32(); + break; + } + case 2: { + message.endIndex = reader.int32(); + break; + } + case 3: { + message.uri = reader.string(); + break; + } + case 4: { + message.license = reader.string(); break; } default: @@ -11405,119 +13751,142 @@ }; /** - * Decodes a GroundingPassages message from the specified reader or buffer, length delimited. + * Decodes a CitationSource message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.ai.generativelanguage.v1beta.GroundingPassages} GroundingPassages + * @returns {google.ai.generativelanguage.v1beta.CitationSource} CitationSource * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - GroundingPassages.decodeDelimited = function decodeDelimited(reader) { + CitationSource.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a GroundingPassages message. + * Verifies a CitationSource message. * @function verify - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - GroundingPassages.verify = function verify(message) { + CitationSource.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.passages != null && message.hasOwnProperty("passages")) { - if (!Array.isArray(message.passages)) - return "passages: array expected"; - for (var i = 0; i < message.passages.length; ++i) { - var error = $root.google.ai.generativelanguage.v1beta.GroundingPassage.verify(message.passages[i]); - if (error) - return "passages." + error; - } + var properties = {}; + if (message.startIndex != null && message.hasOwnProperty("startIndex")) { + properties._startIndex = 1; + if (!$util.isInteger(message.startIndex)) + return "startIndex: integer expected"; + } + if (message.endIndex != null && message.hasOwnProperty("endIndex")) { + properties._endIndex = 1; + if (!$util.isInteger(message.endIndex)) + return "endIndex: integer expected"; + } + if (message.uri != null && message.hasOwnProperty("uri")) { + properties._uri = 1; + if (!$util.isString(message.uri)) + return "uri: string expected"; + } + if (message.license != null && message.hasOwnProperty("license")) { + properties._license = 1; + if (!$util.isString(message.license)) + return "license: string expected"; } return null; }; /** - * Creates a GroundingPassages message from a plain object. Also converts values to their respective internal types. + * Creates a CitationSource message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @static * @param {Object.} object Plain object - * @returns {google.ai.generativelanguage.v1beta.GroundingPassages} GroundingPassages + * @returns {google.ai.generativelanguage.v1beta.CitationSource} CitationSource */ - GroundingPassages.fromObject = function fromObject(object) { - if (object instanceof $root.google.ai.generativelanguage.v1beta.GroundingPassages) + CitationSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.ai.generativelanguage.v1beta.CitationSource) return object; - var message = new $root.google.ai.generativelanguage.v1beta.GroundingPassages(); - if (object.passages) { - if (!Array.isArray(object.passages)) - throw TypeError(".google.ai.generativelanguage.v1beta.GroundingPassages.passages: array expected"); - message.passages = []; - for (var i = 0; i < object.passages.length; ++i) { - if (typeof object.passages[i] !== "object") - throw TypeError(".google.ai.generativelanguage.v1beta.GroundingPassages.passages: object expected"); - message.passages[i] = $root.google.ai.generativelanguage.v1beta.GroundingPassage.fromObject(object.passages[i]); - } - } + var message = new $root.google.ai.generativelanguage.v1beta.CitationSource(); + if (object.startIndex != null) + message.startIndex = object.startIndex | 0; + if (object.endIndex != null) + message.endIndex = object.endIndex | 0; + if (object.uri != null) + message.uri = String(object.uri); + if (object.license != null) + message.license = String(object.license); return message; }; /** - * Creates a plain object from a GroundingPassages message. Also converts values to other types if specified. + * Creates a plain object from a CitationSource message. Also converts values to other types if specified. * @function toObject - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @static - * @param {google.ai.generativelanguage.v1beta.GroundingPassages} message GroundingPassages + * @param {google.ai.generativelanguage.v1beta.CitationSource} message CitationSource * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - GroundingPassages.toObject = function toObject(message, options) { + CitationSource.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) - object.passages = []; - if (message.passages && message.passages.length) { - object.passages = []; - for (var j = 0; j < message.passages.length; ++j) - object.passages[j] = $root.google.ai.generativelanguage.v1beta.GroundingPassage.toObject(message.passages[j], options); + if (message.startIndex != null && message.hasOwnProperty("startIndex")) { + object.startIndex = message.startIndex; + if (options.oneofs) + object._startIndex = "startIndex"; + } + if (message.endIndex != null && message.hasOwnProperty("endIndex")) { + object.endIndex = message.endIndex; + if (options.oneofs) + object._endIndex = "endIndex"; + } + if (message.uri != null && message.hasOwnProperty("uri")) { + object.uri = message.uri; + if (options.oneofs) + object._uri = "uri"; + } + if (message.license != null && message.hasOwnProperty("license")) { + object.license = message.license; + if (options.oneofs) + object._license = "license"; } return object; }; /** - * Converts this GroundingPassages to JSON. + * Converts this CitationSource to JSON. * @function toJSON - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @instance * @returns {Object.} JSON object */ - GroundingPassages.prototype.toJSON = function toJSON() { + CitationSource.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for GroundingPassages + * Gets the default type url for CitationSource * @function getTypeUrl - * @memberof google.ai.generativelanguage.v1beta.GroundingPassages + * @memberof google.ai.generativelanguage.v1beta.CitationSource * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - GroundingPassages.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + CitationSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.GroundingPassages"; + return typeUrlPrefix + "/google.ai.generativelanguage.v1beta.CitationSource"; }; - return GroundingPassages; + return CitationSource; })(); v1beta.DiscussService = (function() { @@ -17345,6 +19714,7 @@ * @property {google.ai.generativelanguage.v1beta.IToolConfig|null} [toolConfig] GenerateContentRequest toolConfig * @property {Array.|null} [safetySettings] GenerateContentRequest safetySettings * @property {google.ai.generativelanguage.v1beta.IGenerationConfig|null} [generationConfig] GenerateContentRequest generationConfig + * @property {string|null} [cachedContent] GenerateContentRequest cachedContent */ /** @@ -17421,6 +19791,14 @@ */ GenerateContentRequest.prototype.generationConfig = null; + /** + * GenerateContentRequest cachedContent. + * @member {string|null|undefined} cachedContent + * @memberof google.ai.generativelanguage.v1beta.GenerateContentRequest + * @instance + */ + GenerateContentRequest.prototype.cachedContent = null; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -17446,6 +19824,17 @@ set: $util.oneOfSetter($oneOfFields) }); + /** + * GenerateContentRequest _cachedContent. + * @member {"cachedContent"|undefined} _cachedContent + * @memberof google.ai.generativelanguage.v1beta.GenerateContentRequest + * @instance + */ + Object.defineProperty(GenerateContentRequest.prototype, "_cachedContent", { + get: $util.oneOfGetter($oneOfFields = ["cachedContent"]), + set: $util.oneOfSetter($oneOfFields) + }); + /** * Creates a new GenerateContentRequest instance using the specified properties. * @function create @@ -17487,6 +19876,8 @@ $root.google.ai.generativelanguage.v1beta.ToolConfig.encode(message.toolConfig, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); if (message.systemInstruction != null && Object.hasOwnProperty.call(message, "systemInstruction")) $root.google.ai.generativelanguage.v1beta.Content.encode(message.systemInstruction, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.cachedContent != null && Object.hasOwnProperty.call(message, "cachedContent")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.cachedContent); return writer; }; @@ -17555,6 +19946,10 @@ message.generationConfig = $root.google.ai.generativelanguage.v1beta.GenerationConfig.decode(reader, reader.uint32()); break; } + case 9: { + message.cachedContent = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -17642,6 +20037,11 @@ return "generationConfig." + error; } } + if (message.cachedContent != null && message.hasOwnProperty("cachedContent")) { + properties._cachedContent = 1; + if (!$util.isString(message.cachedContent)) + return "cachedContent: string expected"; + } return null; }; @@ -17704,6 +20104,8 @@ throw TypeError(".google.ai.generativelanguage.v1beta.GenerateContentRequest.generationConfig: object expected"); message.generationConfig = $root.google.ai.generativelanguage.v1beta.GenerationConfig.fromObject(object.generationConfig); } + if (object.cachedContent != null) + message.cachedContent = String(object.cachedContent); return message; }; @@ -17758,6 +20160,11 @@ if (options.oneofs) object._systemInstruction = "systemInstruction"; } + if (message.cachedContent != null && message.hasOwnProperty("cachedContent")) { + object.cachedContent = message.cachedContent; + if (options.oneofs) + object._cachedContent = "cachedContent"; + } return object; }; @@ -19187,6 +21594,7 @@ * @memberof google.ai.generativelanguage.v1beta.GenerateContentResponse * @interface IUsageMetadata * @property {number|null} [promptTokenCount] UsageMetadata promptTokenCount + * @property {number|null} [cachedContentTokenCount] UsageMetadata cachedContentTokenCount * @property {number|null} [candidatesTokenCount] UsageMetadata candidatesTokenCount * @property {number|null} [totalTokenCount] UsageMetadata totalTokenCount */ @@ -19214,6 +21622,14 @@ */ UsageMetadata.prototype.promptTokenCount = 0; + /** + * UsageMetadata cachedContentTokenCount. + * @member {number} cachedContentTokenCount + * @memberof google.ai.generativelanguage.v1beta.GenerateContentResponse.UsageMetadata + * @instance + */ + UsageMetadata.prototype.cachedContentTokenCount = 0; + /** * UsageMetadata candidatesTokenCount. * @member {number} candidatesTokenCount @@ -19260,6 +21676,8 @@ writer.uint32(/* id 2, wireType 0 =*/16).int32(message.candidatesTokenCount); if (message.totalTokenCount != null && Object.hasOwnProperty.call(message, "totalTokenCount")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.totalTokenCount); + if (message.cachedContentTokenCount != null && Object.hasOwnProperty.call(message, "cachedContentTokenCount")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.cachedContentTokenCount); return writer; }; @@ -19298,6 +21716,10 @@ message.promptTokenCount = reader.int32(); break; } + case 4: { + message.cachedContentTokenCount = reader.int32(); + break; + } case 2: { message.candidatesTokenCount = reader.int32(); break; @@ -19344,6 +21766,9 @@ if (message.promptTokenCount != null && message.hasOwnProperty("promptTokenCount")) if (!$util.isInteger(message.promptTokenCount)) return "promptTokenCount: integer expected"; + if (message.cachedContentTokenCount != null && message.hasOwnProperty("cachedContentTokenCount")) + if (!$util.isInteger(message.cachedContentTokenCount)) + return "cachedContentTokenCount: integer expected"; if (message.candidatesTokenCount != null && message.hasOwnProperty("candidatesTokenCount")) if (!$util.isInteger(message.candidatesTokenCount)) return "candidatesTokenCount: integer expected"; @@ -19367,6 +21792,8 @@ var message = new $root.google.ai.generativelanguage.v1beta.GenerateContentResponse.UsageMetadata(); if (object.promptTokenCount != null) message.promptTokenCount = object.promptTokenCount | 0; + if (object.cachedContentTokenCount != null) + message.cachedContentTokenCount = object.cachedContentTokenCount | 0; if (object.candidatesTokenCount != null) message.candidatesTokenCount = object.candidatesTokenCount | 0; if (object.totalTokenCount != null) @@ -19391,6 +21818,7 @@ object.promptTokenCount = 0; object.candidatesTokenCount = 0; object.totalTokenCount = 0; + object.cachedContentTokenCount = 0; } if (message.promptTokenCount != null && message.hasOwnProperty("promptTokenCount")) object.promptTokenCount = message.promptTokenCount; @@ -19398,6 +21826,8 @@ object.candidatesTokenCount = message.candidatesTokenCount; if (message.totalTokenCount != null && message.hasOwnProperty("totalTokenCount")) object.totalTokenCount = message.totalTokenCount; + if (message.cachedContentTokenCount != null && message.hasOwnProperty("cachedContentTokenCount")) + object.cachedContentTokenCount = message.cachedContentTokenCount; return object; }; @@ -23537,6 +25967,7 @@ * @memberof google.ai.generativelanguage.v1beta * @interface ICountTokensResponse * @property {number|null} [totalTokens] CountTokensResponse totalTokens + * @property {number|null} [cachedContentTokenCount] CountTokensResponse cachedContentTokenCount */ /** @@ -23562,6 +25993,14 @@ */ CountTokensResponse.prototype.totalTokens = 0; + /** + * CountTokensResponse cachedContentTokenCount. + * @member {number} cachedContentTokenCount + * @memberof google.ai.generativelanguage.v1beta.CountTokensResponse + * @instance + */ + CountTokensResponse.prototype.cachedContentTokenCount = 0; + /** * Creates a new CountTokensResponse instance using the specified properties. * @function create @@ -23588,6 +26027,8 @@ writer = $Writer.create(); if (message.totalTokens != null && Object.hasOwnProperty.call(message, "totalTokens")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.totalTokens); + if (message.cachedContentTokenCount != null && Object.hasOwnProperty.call(message, "cachedContentTokenCount")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.cachedContentTokenCount); return writer; }; @@ -23626,6 +26067,10 @@ message.totalTokens = reader.int32(); break; } + case 5: { + message.cachedContentTokenCount = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -23664,6 +26109,9 @@ if (message.totalTokens != null && message.hasOwnProperty("totalTokens")) if (!$util.isInteger(message.totalTokens)) return "totalTokens: integer expected"; + if (message.cachedContentTokenCount != null && message.hasOwnProperty("cachedContentTokenCount")) + if (!$util.isInteger(message.cachedContentTokenCount)) + return "cachedContentTokenCount: integer expected"; return null; }; @@ -23681,6 +26129,8 @@ var message = new $root.google.ai.generativelanguage.v1beta.CountTokensResponse(); if (object.totalTokens != null) message.totalTokens = object.totalTokens | 0; + if (object.cachedContentTokenCount != null) + message.cachedContentTokenCount = object.cachedContentTokenCount | 0; return message; }; @@ -23697,10 +26147,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.totalTokens = 0; + object.cachedContentTokenCount = 0; + } if (message.totalTokens != null && message.hasOwnProperty("totalTokens")) object.totalTokens = message.totalTokens; + if (message.cachedContentTokenCount != null && message.hasOwnProperty("cachedContentTokenCount")) + object.cachedContentTokenCount = message.cachedContentTokenCount; return object; }; @@ -85588,242 +88042,6 @@ return Timestamp; })(); - protobuf.Any = (function() { - - /** - * Properties of an Any. - * @memberof google.protobuf - * @interface IAny - * @property {string|null} [type_url] Any type_url - * @property {Uint8Array|null} [value] Any value - */ - - /** - * Constructs a new Any. - * @memberof google.protobuf - * @classdesc Represents an Any. - * @implements IAny - * @constructor - * @param {google.protobuf.IAny=} [properties] Properties to set - */ - function Any(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]]; - } - - /** - * Any type_url. - * @member {string} type_url - * @memberof google.protobuf.Any - * @instance - */ - Any.prototype.type_url = ""; - - /** - * Any value. - * @member {Uint8Array} value - * @memberof google.protobuf.Any - * @instance - */ - Any.prototype.value = $util.newBuffer([]); - - /** - * Creates a new Any instance using the specified properties. - * @function create - * @memberof google.protobuf.Any - * @static - * @param {google.protobuf.IAny=} [properties] Properties to set - * @returns {google.protobuf.Any} Any instance - */ - Any.create = function create(properties) { - return new Any(properties); - }; - - /** - * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. - * @function encode - * @memberof google.protobuf.Any - * @static - * @param {google.protobuf.IAny} message Any message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Any.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.type_url != null && Object.hasOwnProperty.call(message, "type_url")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.type_url); - if (message.value != null && Object.hasOwnProperty.call(message, "value")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.value); - return writer; - }; - - /** - * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.Any - * @static - * @param {google.protobuf.IAny} message Any message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Any.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an Any message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.Any - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.Any} Any - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Any.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.protobuf.Any(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: { - message.type_url = reader.string(); - break; - } - case 2: { - message.value = reader.bytes(); - break; - } - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an Any message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.Any - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.Any} Any - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Any.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an Any message. - * @function verify - * @memberof google.protobuf.Any - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Any.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.type_url != null && message.hasOwnProperty("type_url")) - if (!$util.isString(message.type_url)) - return "type_url: string expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) - return "value: buffer expected"; - return null; - }; - - /** - * Creates an Any message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.Any - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.Any} Any - */ - Any.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.Any) - return object; - var message = new $root.google.protobuf.Any(); - if (object.type_url != null) - message.type_url = String(object.type_url); - if (object.value != null) - if (typeof object.value === "string") - $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); - else if (object.value.length >= 0) - message.value = object.value; - return message; - }; - - /** - * Creates a plain object from an Any message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.Any - * @static - * @param {google.protobuf.Any} message Any - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Any.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.type_url = ""; - if (options.bytes === String) - object.value = ""; - else { - object.value = []; - if (options.bytes !== Array) - object.value = $util.newBuffer(object.value); - } - } - if (message.type_url != null && message.hasOwnProperty("type_url")) - object.type_url = message.type_url; - if (message.value != null && message.hasOwnProperty("value")) - object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; - return object; - }; - - /** - * Converts this Any to JSON. - * @function toJSON - * @memberof google.protobuf.Any - * @instance - * @returns {Object.} JSON object - */ - Any.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - /** - * Gets the default type url for Any - * @function getTypeUrl - * @memberof google.protobuf.Any - * @static - * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns {string} The default type url - */ - Any.getTypeUrl = function getTypeUrl(typeUrlPrefix) { - if (typeUrlPrefix === undefined) { - typeUrlPrefix = "type.googleapis.com"; - } - return typeUrlPrefix + "/google.protobuf.Any"; - }; - - return Any; - })(); - protobuf.Empty = (function() { /** @@ -86218,6 +88436,242 @@ return FieldMask; })(); + protobuf.Any = (function() { + + /** + * Properties of an Any. + * @memberof google.protobuf + * @interface IAny + * @property {string|null} [type_url] Any type_url + * @property {Uint8Array|null} [value] Any value + */ + + /** + * Constructs a new Any. + * @memberof google.protobuf + * @classdesc Represents an Any. + * @implements IAny + * @constructor + * @param {google.protobuf.IAny=} [properties] Properties to set + */ + function Any(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]]; + } + + /** + * Any type_url. + * @member {string} type_url + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.type_url = ""; + + /** + * Any value. + * @member {Uint8Array} value + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.value = $util.newBuffer([]); + + /** + * Creates a new Any instance using the specified properties. + * @function create + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny=} [properties] Properties to set + * @returns {google.protobuf.Any} Any instance + */ + Any.create = function create(properties) { + return new Any(properties); + }; + + /** + * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny} message Any message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Any.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type_url != null && Object.hasOwnProperty.call(message, "type_url")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.type_url); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.value); + return writer; + }; + + /** + * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny} message Any message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Any.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Any message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Any + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Any} Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Any.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.protobuf.Any(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type_url = reader.string(); + break; + } + case 2: { + message.value = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Any message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Any + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Any} Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Any.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Any message. + * @function verify + * @memberof google.protobuf.Any + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Any.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type_url != null && message.hasOwnProperty("type_url")) + if (!$util.isString(message.type_url)) + return "type_url: string expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) + return "value: buffer expected"; + return null; + }; + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Any + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Any} Any + */ + Any.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Any) + return object; + var message = new $root.google.protobuf.Any(); + if (object.type_url != null) + message.type_url = String(object.type_url); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length >= 0) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.Any} message Any + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Any.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type_url = ""; + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + } + if (message.type_url != null && message.hasOwnProperty("type_url")) + object.type_url = message.type_url; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this Any to JSON. + * @function toJSON + * @memberof google.protobuf.Any + * @instance + * @returns {Object.} JSON object + */ + Any.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Any + * @function getTypeUrl + * @memberof google.protobuf.Any + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Any.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Any"; + }; + + return Any; + })(); + return protobuf; })(); diff --git a/packages/google-ai-generativelanguage/protos/protos.json b/packages/google-ai-generativelanguage/protos/protos.json index 058401725d7..3e4b98f3c19 100644 --- a/packages/google-ai-generativelanguage/protos/protos.json +++ b/packages/google-ai-generativelanguage/protos/protos.json @@ -906,70 +906,327 @@ "java_package": "com.google.ai.generativelanguage.v1beta" }, "nested": { - "CitationMetadata": { + "CacheService": { + "options": { + "(google.api.default_host)": "generativelanguage.googleapis.com" + }, + "methods": { + "ListCachedContents": { + "requestType": "ListCachedContentsRequest", + "responseType": "ListCachedContentsResponse", + "options": { + "(google.api.http).get": "/v1beta/cachedContents", + "(google.api.method_signature)": "" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1beta/cachedContents" + } + }, + { + "(google.api.method_signature)": "" + } + ] + }, + "CreateCachedContent": { + "requestType": "CreateCachedContentRequest", + "responseType": "CachedContent", + "options": { + "(google.api.http).post": "/v1beta/cachedContents", + "(google.api.http).body": "cached_content", + "(google.api.method_signature)": "cached_content" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta/cachedContents", + "body": "cached_content" + } + }, + { + "(google.api.method_signature)": "cached_content" + } + ] + }, + "GetCachedContent": { + "requestType": "GetCachedContentRequest", + "responseType": "CachedContent", + "options": { + "(google.api.http).get": "/v1beta/{name=cachedContents/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1beta/{name=cachedContents/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateCachedContent": { + "requestType": "UpdateCachedContentRequest", + "responseType": "CachedContent", + "options": { + "(google.api.http).patch": "/v1beta/{cached_content.name=cachedContents/*}", + "(google.api.http).body": "cached_content", + "(google.api.method_signature)": "cached_content,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v1beta/{cached_content.name=cachedContents/*}", + "body": "cached_content" + } + }, + { + "(google.api.method_signature)": "cached_content,update_mask" + } + ] + }, + "DeleteCachedContent": { + "requestType": "DeleteCachedContentRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1beta/{name=cachedContents/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1beta/{name=cachedContents/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + } + } + }, + "ListCachedContentsRequest": { "fields": { - "citationSources": { + "pageSize": { + "type": "int32", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ListCachedContentsResponse": { + "fields": { + "cachedContents": { "rule": "repeated", - "type": "CitationSource", + "type": "CachedContent", "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 } } }, - "CitationSource": { + "CreateCachedContentRequest": { + "fields": { + "cachedContent": { + "type": "CachedContent", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "GetCachedContentRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "generativelanguage.googleapis.com/CachedContent" + } + } + } + }, + "UpdateCachedContentRequest": { + "fields": { + "cachedContent": { + "type": "CachedContent", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "DeleteCachedContentRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "generativelanguage.googleapis.com/CachedContent" + } + } + } + }, + "CachedContent": { + "options": { + "(google.api.resource).type": "generativelanguage.googleapis.com/CachedContent", + "(google.api.resource).pattern": "cachedContents/{id}", + "(google.api.resource).plural": "cachedContents", + "(google.api.resource).singular": "cachedContent" + }, "oneofs": { - "_startIndex": { + "expiration": { "oneof": [ - "startIndex" + "expireTime", + "ttl" ] }, - "_endIndex": { + "_name": { "oneof": [ - "endIndex" + "name" ] }, - "_uri": { + "_displayName": { "oneof": [ - "uri" + "displayName" ] }, - "_license": { + "_model": { "oneof": [ - "license" + "model" + ] + }, + "_systemInstruction": { + "oneof": [ + "systemInstruction" + ] + }, + "_toolConfig": { + "oneof": [ + "toolConfig" ] } }, "fields": { - "startIndex": { - "type": "int32", + "expireTime": { + "type": "google.protobuf.Timestamp", + "id": 9 + }, + "ttl": { + "type": "google.protobuf.Duration", + "id": 10, + "options": { + "(google.api.field_behavior)": "INPUT_ONLY" + } + }, + "name": { + "type": "string", "id": 1, "options": { "(google.api.field_behavior)": "OPTIONAL", "proto3_optional": true } }, - "endIndex": { - "type": "int32", - "id": 2, + "displayName": { + "type": "string", + "id": 11, "options": { - "(google.api.field_behavior)": "OPTIONAL", + "(google.api.field_behavior)": "IMMUTABLE", "proto3_optional": true } }, - "uri": { + "model": { "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "generativelanguage.googleapis.com/Model", + "proto3_optional": true + } + }, + "systemInstruction": { + "type": "Content", "id": 3, "options": { - "(google.api.field_behavior)": "OPTIONAL", + "(google.api.field_behavior)": "INPUT_ONLY", "proto3_optional": true } }, - "license": { - "type": "string", + "contents": { + "rule": "repeated", + "type": "Content", "id": 4, "options": { - "(google.api.field_behavior)": "OPTIONAL", + "(google.api.field_behavior)": "INPUT_ONLY" + } + }, + "tools": { + "rule": "repeated", + "type": "Tool", + "id": 5, + "options": { + "(google.api.field_behavior)": "INPUT_ONLY" + } + }, + "toolConfig": { + "type": "ToolConfig", + "id": 6, + "options": { + "(google.api.field_behavior)": "INPUT_ONLY", "proto3_optional": true } + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 8, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "usageMetadata": { + "type": "UsageMetadata", + "id": 12, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "UsageMetadata": { + "fields": { + "totalTokenCount": { + "type": "int32", + "id": 1 + } + } } } }, @@ -1286,6 +1543,73 @@ } } }, + "CitationMetadata": { + "fields": { + "citationSources": { + "rule": "repeated", + "type": "CitationSource", + "id": 1 + } + } + }, + "CitationSource": { + "oneofs": { + "_startIndex": { + "oneof": [ + "startIndex" + ] + }, + "_endIndex": { + "oneof": [ + "endIndex" + ] + }, + "_uri": { + "oneof": [ + "uri" + ] + }, + "_license": { + "oneof": [ + "license" + ] + } + }, + "fields": { + "startIndex": { + "type": "int32", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL", + "proto3_optional": true + } + }, + "endIndex": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL", + "proto3_optional": true + } + }, + "uri": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL", + "proto3_optional": true + } + }, + "license": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL", + "proto3_optional": true + } + } + } + }, "DiscussService": { "options": { "(google.api.default_host)": "generativelanguage.googleapis.com" @@ -2073,6 +2397,11 @@ "oneof": [ "generationConfig" ] + }, + "_cachedContent": { + "oneof": [ + "cachedContent" + ] } }, "fields": { @@ -2130,6 +2459,15 @@ "(google.api.field_behavior)": "OPTIONAL", "proto3_optional": true } + }, + "cachedContent": { + "type": "string", + "id": 9, + "options": { + "(google.api.field_behavior)": "OPTIONAL", + "(google.api.resource_reference).type": "generativelanguage.googleapis.com/CachedContent", + "proto3_optional": true + } } } }, @@ -2331,6 +2669,10 @@ "type": "int32", "id": 1 }, + "cachedContentTokenCount": { + "type": "int32", + "id": 4 + }, "candidatesTokenCount": { "type": "int32", "id": 2 @@ -2777,6 +3119,10 @@ "totalTokens": { "type": "int32", "id": 1 + }, + "cachedContentTokenCount": { + "type": "int32", + "id": 5 } } }, @@ -9855,18 +10201,6 @@ } } }, - "Any": { - "fields": { - "type_url": { - "type": "string", - "id": 1 - }, - "value": { - "type": "bytes", - "id": 2 - } - } - }, "Empty": { "fields": {} }, @@ -9878,6 +10212,18 @@ "id": 1 } } + }, + "Any": { + "fields": { + "type_url": { + "type": "string", + "id": 1 + }, + "value": { + "type": "bytes", + "id": 2 + } + } } } }, diff --git a/packages/google-ai-generativelanguage/samples/README.md b/packages/google-ai-generativelanguage/samples/README.md index a59aacafb15..12ec64d908e 100644 --- a/packages/google-ai-generativelanguage/samples/README.md +++ b/packages/google-ai-generativelanguage/samples/README.md @@ -19,6 +19,11 @@ * [Generative_service.stream_generate_content](#generative_service.stream_generate_content) * [Model_service.get_model](#model_service.get_model) * [Model_service.list_models](#model_service.list_models) + * [Cache_service.create_cached_content](#cache_service.create_cached_content) + * [Cache_service.delete_cached_content](#cache_service.delete_cached_content) + * [Cache_service.get_cached_content](#cache_service.get_cached_content) + * [Cache_service.list_cached_contents](#cache_service.list_cached_contents) + * [Cache_service.update_cached_content](#cache_service.update_cached_content) * [Discuss_service.count_message_tokens](#discuss_service.count_message_tokens) * [Discuss_service.generate_message](#discuss_service.generate_message) * [File_service.create_file](#file_service.create_file) @@ -229,6 +234,91 @@ __Usage:__ +### Cache_service.create_cached_content + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.create_cached_content.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.create_cached_content.js,samples/README.md) + +__Usage:__ + + +`node packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.create_cached_content.js` + + +----- + + + + +### Cache_service.delete_cached_content + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.delete_cached_content.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.delete_cached_content.js,samples/README.md) + +__Usage:__ + + +`node packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.delete_cached_content.js` + + +----- + + + + +### Cache_service.get_cached_content + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.get_cached_content.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.get_cached_content.js,samples/README.md) + +__Usage:__ + + +`node packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.get_cached_content.js` + + +----- + + + + +### Cache_service.list_cached_contents + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.list_cached_contents.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.list_cached_contents.js,samples/README.md) + +__Usage:__ + + +`node packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.list_cached_contents.js` + + +----- + + + + +### Cache_service.update_cached_content + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.update_cached_content.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.update_cached_content.js,samples/README.md) + +__Usage:__ + + +`node packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.update_cached_content.js` + + +----- + + + + ### Discuss_service.count_message_tokens View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-ai-generativelanguage/samples/generated/v1beta/discuss_service.count_message_tokens.js). diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.create_cached_content.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.create_cached_content.js new file mode 100644 index 00000000000..9a0c2d33609 --- /dev/null +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.create_cached_content.js @@ -0,0 +1,61 @@ +// Copyright 2024 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(cachedContent) { + // [START generativelanguage_v1beta_generated_CacheService_CreateCachedContent_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 cached content to create. + */ + // const cachedContent = {} + + // Imports the Generativelanguage library + const {CacheServiceClient} = require('@google-ai/generativelanguage').v1beta; + + // Instantiates a client + const generativelanguageClient = new CacheServiceClient(); + + async function callCreateCachedContent() { + // Construct request + const request = { + cachedContent, + }; + + // Run request + const response = await generativelanguageClient.createCachedContent(request); + console.log(response); + } + + callCreateCachedContent(); + // [END generativelanguage_v1beta_generated_CacheService_CreateCachedContent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.delete_cached_content.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.delete_cached_content.js new file mode 100644 index 00000000000..d7aea77c3b0 --- /dev/null +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.delete_cached_content.js @@ -0,0 +1,62 @@ +// Copyright 2024 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 generativelanguage_v1beta_generated_CacheService_DeleteCachedContent_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 referring to the content cache entry + * Format: `cachedContents/{id}` + */ + // const name = 'abc123' + + // Imports the Generativelanguage library + const {CacheServiceClient} = require('@google-ai/generativelanguage').v1beta; + + // Instantiates a client + const generativelanguageClient = new CacheServiceClient(); + + async function callDeleteCachedContent() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await generativelanguageClient.deleteCachedContent(request); + console.log(response); + } + + callDeleteCachedContent(); + // [END generativelanguage_v1beta_generated_CacheService_DeleteCachedContent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.get_cached_content.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.get_cached_content.js new file mode 100644 index 00000000000..13d13fcde5f --- /dev/null +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.get_cached_content.js @@ -0,0 +1,62 @@ +// Copyright 2024 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 generativelanguage_v1beta_generated_CacheService_GetCachedContent_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 referring to the content cache entry. + * Format: `cachedContents/{id}` + */ + // const name = 'abc123' + + // Imports the Generativelanguage library + const {CacheServiceClient} = require('@google-ai/generativelanguage').v1beta; + + // Instantiates a client + const generativelanguageClient = new CacheServiceClient(); + + async function callGetCachedContent() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await generativelanguageClient.getCachedContent(request); + console.log(response); + } + + callGetCachedContent(); + // [END generativelanguage_v1beta_generated_CacheService_GetCachedContent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.list_cached_contents.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.list_cached_contents.js new file mode 100644 index 00000000000..6ebd9aea606 --- /dev/null +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.list_cached_contents.js @@ -0,0 +1,72 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START generativelanguage_v1beta_generated_CacheService_ListCachedContents_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. + */ + /** + * Optional. The maximum number of cached contents to return. The service may + * return fewer than this value. If unspecified, some default (under maximum) + * number of items will be returned. The maximum value is 1000; values above + * 1000 will be coerced to 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListCachedContents` call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to `ListCachedContents` must + * match the call that provided the page token. + */ + // const pageToken = 'abc123' + + // Imports the Generativelanguage library + const {CacheServiceClient} = require('@google-ai/generativelanguage').v1beta; + + // Instantiates a client + const generativelanguageClient = new CacheServiceClient(); + + async function callListCachedContents() { + // Construct request + const request = { + }; + + // Run request + const iterable = generativelanguageClient.listCachedContentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCachedContents(); + // [END generativelanguage_v1beta_generated_CacheService_ListCachedContents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.update_cached_content.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.update_cached_content.js new file mode 100644 index 00000000000..2fa9bbff4eb --- /dev/null +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/cache_service.update_cached_content.js @@ -0,0 +1,65 @@ +// Copyright 2024 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(cachedContent) { + // [START generativelanguage_v1beta_generated_CacheService_UpdateCachedContent_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 content cache entry to update + */ + // const cachedContent = {} + /** + * The list of fields to update. + */ + // const updateMask = {} + + // Imports the Generativelanguage library + const {CacheServiceClient} = require('@google-ai/generativelanguage').v1beta; + + // Instantiates a client + const generativelanguageClient = new CacheServiceClient(); + + async function callUpdateCachedContent() { + // Construct request + const request = { + cachedContent, + }; + + // Run request + const response = await generativelanguageClient.updateCachedContent(request); + console.log(response); + } + + callUpdateCachedContent(); + // [END generativelanguage_v1beta_generated_CacheService_UpdateCachedContent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/generative_service.generate_content.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/generative_service.generate_content.js index 2f4b7e144eb..08e1ef7db2b 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta/generative_service.generate_content.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/generative_service.generate_content.js @@ -76,6 +76,13 @@ function main(model, contents) { * Optional. Configuration options for model generation and outputs. */ // const generationConfig = {} + /** + * Optional. The name of the cached content used as context to serve the + * prediction. Note: only used in explicit caching, where users can have + * control over caching (e.g. what content to cache) and enjoy guaranteed cost + * savings. Format: `cachedContents/{cachedContent}` + */ + // const cachedContent = 'abc123' // Imports the Generativelanguage library const {GenerativeServiceClient} = require('@google-ai/generativelanguage').v1beta; diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/generative_service.stream_generate_content.js b/packages/google-ai-generativelanguage/samples/generated/v1beta/generative_service.stream_generate_content.js index f0a6e33d067..45d60f0e222 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta/generative_service.stream_generate_content.js +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/generative_service.stream_generate_content.js @@ -76,6 +76,13 @@ function main(model, contents) { * Optional. Configuration options for model generation and outputs. */ // const generationConfig = {} + /** + * Optional. The name of the cached content used as context to serve the + * prediction. Note: only used in explicit caching, where users can have + * control over caching (e.g. what content to cache) and enjoy guaranteed cost + * savings. Format: `cachedContents/{cachedContent}` + */ + // const cachedContent = 'abc123' // Imports the Generativelanguage library const {GenerativeServiceClient} = require('@google-ai/generativelanguage').v1beta; diff --git a/packages/google-ai-generativelanguage/samples/generated/v1beta/snippet_metadata_google.ai.generativelanguage.v1beta.json b/packages/google-ai-generativelanguage/samples/generated/v1beta/snippet_metadata_google.ai.generativelanguage.v1beta.json index 33a3f03b659..96460da198a 100644 --- a/packages/google-ai-generativelanguage/samples/generated/v1beta/snippet_metadata_google.ai.generativelanguage.v1beta.json +++ b/packages/google-ai-generativelanguage/samples/generated/v1beta/snippet_metadata_google.ai.generativelanguage.v1beta.json @@ -11,9 +11,217 @@ ] }, "snippets": [ + { + "regionTag": "generativelanguage_v1beta_generated_CacheService_ListCachedContents_async", + "title": "CacheService listCachedContents Sample", + "origin": "API_DEFINITION", + "description": " Lists CachedContents.", + "canonical": true, + "file": "cache_service.list_cached_contents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCachedContents", + "fullName": "google.ai.generativelanguage.v1beta.CacheService.ListCachedContents", + "async": true, + "parameters": [ + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.ai.generativelanguage.v1beta.ListCachedContentsResponse", + "client": { + "shortName": "CacheServiceClient", + "fullName": "google.ai.generativelanguage.v1beta.CacheServiceClient" + }, + "method": { + "shortName": "ListCachedContents", + "fullName": "google.ai.generativelanguage.v1beta.CacheService.ListCachedContents", + "service": { + "shortName": "CacheService", + "fullName": "google.ai.generativelanguage.v1beta.CacheService" + } + } + } + }, + { + "regionTag": "generativelanguage_v1beta_generated_CacheService_CreateCachedContent_async", + "title": "CacheService createCachedContent Sample", + "origin": "API_DEFINITION", + "description": " Creates CachedContent resource.", + "canonical": true, + "file": "cache_service.create_cached_content.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateCachedContent", + "fullName": "google.ai.generativelanguage.v1beta.CacheService.CreateCachedContent", + "async": true, + "parameters": [ + { + "name": "cached_content", + "type": ".google.ai.generativelanguage.v1beta.CachedContent" + } + ], + "resultType": ".google.ai.generativelanguage.v1beta.CachedContent", + "client": { + "shortName": "CacheServiceClient", + "fullName": "google.ai.generativelanguage.v1beta.CacheServiceClient" + }, + "method": { + "shortName": "CreateCachedContent", + "fullName": "google.ai.generativelanguage.v1beta.CacheService.CreateCachedContent", + "service": { + "shortName": "CacheService", + "fullName": "google.ai.generativelanguage.v1beta.CacheService" + } + } + } + }, + { + "regionTag": "generativelanguage_v1beta_generated_CacheService_GetCachedContent_async", + "title": "CacheService getCachedContent Sample", + "origin": "API_DEFINITION", + "description": " Reads CachedContent resource.", + "canonical": true, + "file": "cache_service.get_cached_content.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCachedContent", + "fullName": "google.ai.generativelanguage.v1beta.CacheService.GetCachedContent", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.ai.generativelanguage.v1beta.CachedContent", + "client": { + "shortName": "CacheServiceClient", + "fullName": "google.ai.generativelanguage.v1beta.CacheServiceClient" + }, + "method": { + "shortName": "GetCachedContent", + "fullName": "google.ai.generativelanguage.v1beta.CacheService.GetCachedContent", + "service": { + "shortName": "CacheService", + "fullName": "google.ai.generativelanguage.v1beta.CacheService" + } + } + } + }, + { + "regionTag": "generativelanguage_v1beta_generated_CacheService_UpdateCachedContent_async", + "title": "CacheService updateCachedContent Sample", + "origin": "API_DEFINITION", + "description": " Updates CachedContent resource (only expiration is updatable).", + "canonical": true, + "file": "cache_service.update_cached_content.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCachedContent", + "fullName": "google.ai.generativelanguage.v1beta.CacheService.UpdateCachedContent", + "async": true, + "parameters": [ + { + "name": "cached_content", + "type": ".google.ai.generativelanguage.v1beta.CachedContent" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.ai.generativelanguage.v1beta.CachedContent", + "client": { + "shortName": "CacheServiceClient", + "fullName": "google.ai.generativelanguage.v1beta.CacheServiceClient" + }, + "method": { + "shortName": "UpdateCachedContent", + "fullName": "google.ai.generativelanguage.v1beta.CacheService.UpdateCachedContent", + "service": { + "shortName": "CacheService", + "fullName": "google.ai.generativelanguage.v1beta.CacheService" + } + } + } + }, + { + "regionTag": "generativelanguage_v1beta_generated_CacheService_DeleteCachedContent_async", + "title": "CacheService deleteCachedContent Sample", + "origin": "API_DEFINITION", + "description": " Deletes CachedContent resource.", + "canonical": true, + "file": "cache_service.delete_cached_content.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteCachedContent", + "fullName": "google.ai.generativelanguage.v1beta.CacheService.DeleteCachedContent", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CacheServiceClient", + "fullName": "google.ai.generativelanguage.v1beta.CacheServiceClient" + }, + "method": { + "shortName": "DeleteCachedContent", + "fullName": "google.ai.generativelanguage.v1beta.CacheService.DeleteCachedContent", + "service": { + "shortName": "CacheService", + "fullName": "google.ai.generativelanguage.v1beta.CacheService" + } + } + } + }, { "regionTag": "generativelanguage_v1beta_generated_DiscussService_GenerateMessage_async", - "title": "DiscussService generateMessage Sample", + "title": "CacheService generateMessage Sample", "origin": "API_DEFINITION", "description": " Generates a response from the model given an input `MessagePrompt`.", "canonical": true, @@ -73,7 +281,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_DiscussService_CountMessageTokens_async", - "title": "DiscussService countMessageTokens Sample", + "title": "CacheService countMessageTokens Sample", "origin": "API_DEFINITION", "description": " Runs a model's tokenizer on a string and returns the token count.", "canonical": true, @@ -117,7 +325,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_FileService_CreateFile_async", - "title": "DiscussService createFile Sample", + "title": "CacheService createFile Sample", "origin": "API_DEFINITION", "description": " Creates a `File`.", "canonical": true, @@ -157,7 +365,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_FileService_ListFiles_async", - "title": "DiscussService listFiles Sample", + "title": "CacheService listFiles Sample", "origin": "API_DEFINITION", "description": " Lists the metadata for `File`s owned by the requesting project.", "canonical": true, @@ -201,7 +409,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_FileService_GetFile_async", - "title": "DiscussService getFile Sample", + "title": "CacheService getFile Sample", "origin": "API_DEFINITION", "description": " Gets the metadata for the given `File`.", "canonical": true, @@ -241,7 +449,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_FileService_DeleteFile_async", - "title": "DiscussService deleteFile Sample", + "title": "CacheService deleteFile Sample", "origin": "API_DEFINITION", "description": " Deletes the `File`.", "canonical": true, @@ -281,7 +489,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_GenerativeService_GenerateContent_async", - "title": "DiscussService generateContent Sample", + "title": "CacheService generateContent Sample", "origin": "API_DEFINITION", "description": " Generates a response from the model given an input `GenerateContentRequest`. Input capabilities differ between models, including tuned models. See the [model guide](https://ai.google.dev/models/gemini) and [tuning guide](https://ai.google.dev/docs/model_tuning_guidance) for details.", "canonical": true, @@ -290,7 +498,7 @@ "segments": [ { "start": 25, - "end": 98, + "end": 105, "type": "FULL" } ], @@ -326,6 +534,10 @@ { "name": "generation_config", "type": ".google.ai.generativelanguage.v1beta.GenerationConfig" + }, + { + "name": "cached_content", + "type": "TYPE_STRING" } ], "resultType": ".google.ai.generativelanguage.v1beta.GenerateContentResponse", @@ -345,7 +557,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_GenerativeService_GenerateAnswer_async", - "title": "DiscussService generateAnswer Sample", + "title": "CacheService generateAnswer Sample", "origin": "API_DEFINITION", "description": " Generates a grounded answer from the model given an input `GenerateAnswerRequest`.", "canonical": true, @@ -409,7 +621,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_GenerativeService_StreamGenerateContent_async", - "title": "DiscussService streamGenerateContent Sample", + "title": "CacheService streamGenerateContent Sample", "origin": "API_DEFINITION", "description": " Generates a streamed response from the model given an input `GenerateContentRequest`.", "canonical": true, @@ -418,7 +630,7 @@ "segments": [ { "start": 25, - "end": 100, + "end": 107, "type": "FULL" } ], @@ -454,6 +666,10 @@ { "name": "generation_config", "type": ".google.ai.generativelanguage.v1beta.GenerationConfig" + }, + { + "name": "cached_content", + "type": "TYPE_STRING" } ], "resultType": ".google.ai.generativelanguage.v1beta.GenerateContentResponse", @@ -473,7 +689,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_GenerativeService_EmbedContent_async", - "title": "DiscussService embedContent Sample", + "title": "CacheService embedContent Sample", "origin": "API_DEFINITION", "description": " Generates an embedding from the model given an input `Content`.", "canonical": true, @@ -529,7 +745,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_GenerativeService_BatchEmbedContents_async", - "title": "DiscussService batchEmbedContents Sample", + "title": "CacheService batchEmbedContents Sample", "origin": "API_DEFINITION", "description": " Generates multiple embeddings from the model given input text in a synchronous call.", "canonical": true, @@ -573,7 +789,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_GenerativeService_CountTokens_async", - "title": "DiscussService countTokens Sample", + "title": "CacheService countTokens Sample", "origin": "API_DEFINITION", "description": " Runs a model's tokenizer on input content and returns the token count.", "canonical": true, @@ -621,7 +837,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_ModelService_GetModel_async", - "title": "DiscussService getModel Sample", + "title": "CacheService getModel Sample", "origin": "API_DEFINITION", "description": " Gets information about a specific Model.", "canonical": true, @@ -661,7 +877,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_ModelService_ListModels_async", - "title": "DiscussService listModels Sample", + "title": "CacheService listModels Sample", "origin": "API_DEFINITION", "description": " Lists models available through the API.", "canonical": true, @@ -705,7 +921,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_ModelService_GetTunedModel_async", - "title": "DiscussService getTunedModel Sample", + "title": "CacheService getTunedModel Sample", "origin": "API_DEFINITION", "description": " Gets information about a specific TunedModel.", "canonical": true, @@ -745,7 +961,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_ModelService_ListTunedModels_async", - "title": "DiscussService listTunedModels Sample", + "title": "CacheService listTunedModels Sample", "origin": "API_DEFINITION", "description": " Lists tuned models owned by the user.", "canonical": true, @@ -793,7 +1009,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_ModelService_CreateTunedModel_async", - "title": "DiscussService createTunedModel Sample", + "title": "CacheService createTunedModel Sample", "origin": "API_DEFINITION", "description": " Creates a tuned model. Intermediate tuning progress (if any) is accessed through the [google.longrunning.Operations] service. Status and results can be accessed through the Operations service. Example: GET /v1/tunedModels/az2mb0bpw6i/operations/000-111-222", "canonical": true, @@ -837,7 +1053,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_ModelService_UpdateTunedModel_async", - "title": "DiscussService updateTunedModel Sample", + "title": "CacheService updateTunedModel Sample", "origin": "API_DEFINITION", "description": " Updates a tuned model.", "canonical": true, @@ -881,7 +1097,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_ModelService_DeleteTunedModel_async", - "title": "DiscussService deleteTunedModel Sample", + "title": "CacheService deleteTunedModel Sample", "origin": "API_DEFINITION", "description": " Deletes a tuned model.", "canonical": true, @@ -921,7 +1137,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_PermissionService_CreatePermission_async", - "title": "DiscussService createPermission Sample", + "title": "CacheService createPermission Sample", "origin": "API_DEFINITION", "description": " Create a permission to a specific resource.", "canonical": true, @@ -965,7 +1181,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_PermissionService_GetPermission_async", - "title": "DiscussService getPermission Sample", + "title": "CacheService getPermission Sample", "origin": "API_DEFINITION", "description": " Gets information about a specific Permission.", "canonical": true, @@ -1005,7 +1221,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_PermissionService_ListPermissions_async", - "title": "DiscussService listPermissions Sample", + "title": "CacheService listPermissions Sample", "origin": "API_DEFINITION", "description": " Lists permissions for the specific resource.", "canonical": true, @@ -1053,7 +1269,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_PermissionService_UpdatePermission_async", - "title": "DiscussService updatePermission Sample", + "title": "CacheService updatePermission Sample", "origin": "API_DEFINITION", "description": " Updates the permission.", "canonical": true, @@ -1097,7 +1313,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_PermissionService_DeletePermission_async", - "title": "DiscussService deletePermission Sample", + "title": "CacheService deletePermission Sample", "origin": "API_DEFINITION", "description": " Deletes the permission.", "canonical": true, @@ -1137,7 +1353,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_PermissionService_TransferOwnership_async", - "title": "DiscussService transferOwnership Sample", + "title": "CacheService transferOwnership Sample", "origin": "API_DEFINITION", "description": " Transfers ownership of the tuned model. This is the only way to change ownership of the tuned model. The current owner will be downgraded to writer role.", "canonical": true, @@ -1181,7 +1397,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_CreateCorpus_async", - "title": "DiscussService createCorpus Sample", + "title": "CacheService createCorpus Sample", "origin": "API_DEFINITION", "description": " Creates an empty `Corpus`.", "canonical": true, @@ -1221,7 +1437,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_GetCorpus_async", - "title": "DiscussService getCorpus Sample", + "title": "CacheService getCorpus Sample", "origin": "API_DEFINITION", "description": " Gets information about a specific `Corpus`.", "canonical": true, @@ -1261,7 +1477,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_UpdateCorpus_async", - "title": "DiscussService updateCorpus Sample", + "title": "CacheService updateCorpus Sample", "origin": "API_DEFINITION", "description": " Updates a `Corpus`.", "canonical": true, @@ -1305,7 +1521,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_DeleteCorpus_async", - "title": "DiscussService deleteCorpus Sample", + "title": "CacheService deleteCorpus Sample", "origin": "API_DEFINITION", "description": " Deletes a `Corpus`.", "canonical": true, @@ -1349,7 +1565,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_ListCorpora_async", - "title": "DiscussService listCorpora Sample", + "title": "CacheService listCorpora Sample", "origin": "API_DEFINITION", "description": " Lists all `Corpora` owned by the user.", "canonical": true, @@ -1393,7 +1609,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_QueryCorpus_async", - "title": "DiscussService queryCorpus Sample", + "title": "CacheService queryCorpus Sample", "origin": "API_DEFINITION", "description": " Performs semantic search over a `Corpus`.", "canonical": true, @@ -1445,7 +1661,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_CreateDocument_async", - "title": "DiscussService createDocument Sample", + "title": "CacheService createDocument Sample", "origin": "API_DEFINITION", "description": " Creates an empty `Document`.", "canonical": true, @@ -1489,7 +1705,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_GetDocument_async", - "title": "DiscussService getDocument Sample", + "title": "CacheService getDocument Sample", "origin": "API_DEFINITION", "description": " Gets information about a specific `Document`.", "canonical": true, @@ -1529,7 +1745,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_UpdateDocument_async", - "title": "DiscussService updateDocument Sample", + "title": "CacheService updateDocument Sample", "origin": "API_DEFINITION", "description": " Updates a `Document`.", "canonical": true, @@ -1573,7 +1789,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_DeleteDocument_async", - "title": "DiscussService deleteDocument Sample", + "title": "CacheService deleteDocument Sample", "origin": "API_DEFINITION", "description": " Deletes a `Document`.", "canonical": true, @@ -1617,7 +1833,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_ListDocuments_async", - "title": "DiscussService listDocuments Sample", + "title": "CacheService listDocuments Sample", "origin": "API_DEFINITION", "description": " Lists all `Document`s in a `Corpus`.", "canonical": true, @@ -1665,7 +1881,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_QueryDocument_async", - "title": "DiscussService queryDocument Sample", + "title": "CacheService queryDocument Sample", "origin": "API_DEFINITION", "description": " Performs semantic search over a `Document`.", "canonical": true, @@ -1717,7 +1933,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_CreateChunk_async", - "title": "DiscussService createChunk Sample", + "title": "CacheService createChunk Sample", "origin": "API_DEFINITION", "description": " Creates a `Chunk`.", "canonical": true, @@ -1761,7 +1977,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_BatchCreateChunks_async", - "title": "DiscussService batchCreateChunks Sample", + "title": "CacheService batchCreateChunks Sample", "origin": "API_DEFINITION", "description": " Batch create `Chunk`s.", "canonical": true, @@ -1805,7 +2021,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_GetChunk_async", - "title": "DiscussService getChunk Sample", + "title": "CacheService getChunk Sample", "origin": "API_DEFINITION", "description": " Gets information about a specific `Chunk`.", "canonical": true, @@ -1845,7 +2061,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_UpdateChunk_async", - "title": "DiscussService updateChunk Sample", + "title": "CacheService updateChunk Sample", "origin": "API_DEFINITION", "description": " Updates a `Chunk`.", "canonical": true, @@ -1889,7 +2105,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_BatchUpdateChunks_async", - "title": "DiscussService batchUpdateChunks Sample", + "title": "CacheService batchUpdateChunks Sample", "origin": "API_DEFINITION", "description": " Batch update `Chunk`s.", "canonical": true, @@ -1933,7 +2149,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_DeleteChunk_async", - "title": "DiscussService deleteChunk Sample", + "title": "CacheService deleteChunk Sample", "origin": "API_DEFINITION", "description": " Deletes a `Chunk`.", "canonical": true, @@ -1973,7 +2189,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_BatchDeleteChunks_async", - "title": "DiscussService batchDeleteChunks Sample", + "title": "CacheService batchDeleteChunks Sample", "origin": "API_DEFINITION", "description": " Batch delete `Chunk`s.", "canonical": true, @@ -2017,7 +2233,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_RetrieverService_ListChunks_async", - "title": "DiscussService listChunks Sample", + "title": "CacheService listChunks Sample", "origin": "API_DEFINITION", "description": " Lists all `Chunk`s in a `Document`.", "canonical": true, @@ -2065,7 +2281,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_TextService_GenerateText_async", - "title": "DiscussService generateText Sample", + "title": "CacheService generateText Sample", "origin": "API_DEFINITION", "description": " Generates a response from the model given an input message.", "canonical": true, @@ -2137,7 +2353,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_TextService_EmbedText_async", - "title": "DiscussService embedText Sample", + "title": "CacheService embedText Sample", "origin": "API_DEFINITION", "description": " Generates an embedding from the model given an input message.", "canonical": true, @@ -2181,7 +2397,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_TextService_BatchEmbedText_async", - "title": "DiscussService batchEmbedText Sample", + "title": "CacheService batchEmbedText Sample", "origin": "API_DEFINITION", "description": " Generates multiple embeddings from the model given input text in a synchronous call.", "canonical": true, @@ -2229,7 +2445,7 @@ }, { "regionTag": "generativelanguage_v1beta_generated_TextService_CountTextTokens_async", - "title": "DiscussService countTextTokens Sample", + "title": "CacheService countTextTokens Sample", "origin": "API_DEFINITION", "description": " Runs a model's tokenizer on a text and returns the token count.", "canonical": true, diff --git a/packages/google-ai-generativelanguage/src/index.ts b/packages/google-ai-generativelanguage/src/index.ts index ea611c077e6..a36b63f07ea 100644 --- a/packages/google-ai-generativelanguage/src/index.ts +++ b/packages/google-ai-generativelanguage/src/index.ts @@ -21,6 +21,8 @@ import * as v1beta from './v1beta'; import * as v1beta2 from './v1beta2'; import * as v1beta3 from './v1beta3'; +const CacheServiceClient = v1beta.CacheServiceClient; +type CacheServiceClient = v1beta.CacheServiceClient; const DiscussServiceClient = v1beta.DiscussServiceClient; type DiscussServiceClient = v1beta.DiscussServiceClient; const FileServiceClient = v1beta.FileServiceClient; @@ -41,6 +43,7 @@ export { v1beta, v1beta2, v1beta3, + CacheServiceClient, DiscussServiceClient, FileServiceClient, GenerativeServiceClient, @@ -54,6 +57,7 @@ export default { v1beta, v1beta2, v1beta3, + CacheServiceClient, DiscussServiceClient, FileServiceClient, GenerativeServiceClient, diff --git a/packages/google-ai-generativelanguage/src/v1beta/cache_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/cache_service_client.ts new file mode 100644 index 00000000000..9841ecf7b16 --- /dev/null +++ b/packages/google-ai-generativelanguage/src/v1beta/cache_service_client.ts @@ -0,0 +1,1288 @@ +// Copyright 2024 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/cache_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cache_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * API for managing cache of content (CachedContent resources) that can be used + * in GenerativeService requests. This way generate content requests can benefit + * from preprocessing work being done earlier, possibly lowering their + * computational cost. It is intended to be used with large contexts. + * @class + * @memberof v1beta + */ +export class CacheServiceClient { + 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}; + private _universeDomain: string; + private _servicePath: string; + 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}; + cacheServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CacheServiceClient. + * + * @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} [options.fallback] - Use HTTP/1.1 REST mode. + * 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 CacheServiceClient({fallback: true}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CacheServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.' + ); + } + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; + this._servicePath = 'generativelanguage.' + this._universeDomain; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._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 !== this._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 = this._servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === this._servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process === 'object' && '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 { + 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 = { + cachedContentPathTemplate: new this._gaxModule.PathTemplate( + 'cachedContents/{id}' + ), + chunkPathTemplate: new this._gaxModule.PathTemplate( + 'corpora/{corpus}/documents/{document}/chunks/{chunk}' + ), + corpusPathTemplate: new this._gaxModule.PathTemplate('corpora/{corpus}'), + corpusPermissionPathTemplate: new this._gaxModule.PathTemplate( + 'corpora/{corpus}/permissions/{permission}' + ), + documentPathTemplate: new this._gaxModule.PathTemplate( + 'corpora/{corpus}/documents/{document}' + ), + filePathTemplate: new this._gaxModule.PathTemplate('files/{file}'), + modelPathTemplate: new this._gaxModule.PathTemplate('models/{model}'), + tunedModelPathTemplate: new this._gaxModule.PathTemplate( + 'tunedModels/{tuned_model}' + ), + tunedModelPermissionPathTemplate: new this._gaxModule.PathTemplate( + 'tunedModels/{tuned_model}/permissions/{permission}' + ), + }; + + // 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 = { + listCachedContents: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cachedContents' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.ai.generativelanguage.v1beta.CacheService', + 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.cacheServiceStub) { + return this.cacheServiceStub; + } + + // Put together the "service stub" for + // google.ai.generativelanguage.v1beta.CacheService. + this.cacheServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.ai.generativelanguage.v1beta.CacheService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.ai.generativelanguage.v1beta + .CacheService, + 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 cacheServiceStubMethods = [ + 'listCachedContents', + 'createCachedContent', + 'getCachedContent', + 'updateCachedContent', + 'deleteCachedContent', + ]; + for (const methodName of cacheServiceStubMethods) { + const callPromise = this.cacheServiceStub.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.cacheServiceStub; + } + + /** + * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } + return 'generativelanguage.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning' + ); + } + return 'generativelanguage.googleapis.com'; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + + /** + * 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 []; + } + + 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 -- + // ------------------- + /** + * Creates CachedContent resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.ai.generativelanguage.v1beta.CachedContent} request.cachedContent + * Required. The cached content to create. + * @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 protos.google.ai.generativelanguage.v1beta.CachedContent|CachedContent}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/cache_service.create_cached_content.js + * region_tag:generativelanguage_v1beta_generated_CacheService_CreateCachedContent_async + */ + createCachedContent( + request?: protos.google.ai.generativelanguage.v1beta.ICreateCachedContentRequest, + options?: CallOptions + ): Promise< + [ + protos.google.ai.generativelanguage.v1beta.ICachedContent, + ( + | protos.google.ai.generativelanguage.v1beta.ICreateCachedContentRequest + | undefined + ), + {} | undefined, + ] + >; + createCachedContent( + request: protos.google.ai.generativelanguage.v1beta.ICreateCachedContentRequest, + options: CallOptions, + callback: Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.ICreateCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createCachedContent( + request: protos.google.ai.generativelanguage.v1beta.ICreateCachedContentRequest, + callback: Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.ICreateCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createCachedContent( + request?: protos.google.ai.generativelanguage.v1beta.ICreateCachedContentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.ICreateCachedContentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.ICreateCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.ai.generativelanguage.v1beta.ICachedContent, + ( + | protos.google.ai.generativelanguage.v1beta.ICreateCachedContentRequest + | 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 || {}; + this.initialize(); + return this.innerApiCalls.createCachedContent(request, options, callback); + } + /** + * Reads CachedContent resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name referring to the content cache entry. + * Format: `cachedContents/{id}` + * @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 protos.google.ai.generativelanguage.v1beta.CachedContent|CachedContent}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/cache_service.get_cached_content.js + * region_tag:generativelanguage_v1beta_generated_CacheService_GetCachedContent_async + */ + getCachedContent( + request?: protos.google.ai.generativelanguage.v1beta.IGetCachedContentRequest, + options?: CallOptions + ): Promise< + [ + protos.google.ai.generativelanguage.v1beta.ICachedContent, + ( + | protos.google.ai.generativelanguage.v1beta.IGetCachedContentRequest + | undefined + ), + {} | undefined, + ] + >; + getCachedContent( + request: protos.google.ai.generativelanguage.v1beta.IGetCachedContentRequest, + options: CallOptions, + callback: Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.IGetCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getCachedContent( + request: protos.google.ai.generativelanguage.v1beta.IGetCachedContentRequest, + callback: Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.IGetCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getCachedContent( + request?: protos.google.ai.generativelanguage.v1beta.IGetCachedContentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.IGetCachedContentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.IGetCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.ai.generativelanguage.v1beta.ICachedContent, + ( + | protos.google.ai.generativelanguage.v1beta.IGetCachedContentRequest + | 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.getCachedContent(request, options, callback); + } + /** + * Updates CachedContent resource (only expiration is updatable). + * + * @param {Object} request + * The request object that will be sent. + * @param {google.ai.generativelanguage.v1beta.CachedContent} request.cachedContent + * Required. The content cache entry to update + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to update. + * @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 protos.google.ai.generativelanguage.v1beta.CachedContent|CachedContent}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/cache_service.update_cached_content.js + * region_tag:generativelanguage_v1beta_generated_CacheService_UpdateCachedContent_async + */ + updateCachedContent( + request?: protos.google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest, + options?: CallOptions + ): Promise< + [ + protos.google.ai.generativelanguage.v1beta.ICachedContent, + ( + | protos.google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest + | undefined + ), + {} | undefined, + ] + >; + updateCachedContent( + request: protos.google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest, + options: CallOptions, + callback: Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCachedContent( + request: protos.google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest, + callback: Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCachedContent( + request?: protos.google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.ai.generativelanguage.v1beta.ICachedContent, + | protos.google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.ai.generativelanguage.v1beta.ICachedContent, + ( + | protos.google.ai.generativelanguage.v1beta.IUpdateCachedContentRequest + | 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({ + 'cached_content.name': request.cachedContent!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateCachedContent(request, options, callback); + } + /** + * Deletes CachedContent resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name referring to the content cache entry + * Format: `cachedContents/{id}` + * @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 protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/cache_service.delete_cached_content.js + * region_tag:generativelanguage_v1beta_generated_CacheService_DeleteCachedContent_async + */ + deleteCachedContent( + request?: protos.google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest + | undefined + ), + {} | undefined, + ] + >; + deleteCachedContent( + request: protos.google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteCachedContent( + request: protos.google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteCachedContent( + request?: protos.google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.ai.generativelanguage.v1beta.IDeleteCachedContentRequest + | 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.deleteCachedContent(request, options, callback); + } + + /** + * Lists CachedContents. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of cached contents to return. The service may + * return fewer than this value. If unspecified, some default (under maximum) + * number of items will be returned. The maximum value is 1000; values above + * 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListCachedContents` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCachedContents` 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 protos.google.ai.generativelanguage.v1beta.CachedContent|CachedContent}. + * 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 `listCachedContentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listCachedContents( + request?: protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.ai.generativelanguage.v1beta.ICachedContent[], + protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest | null, + protos.google.ai.generativelanguage.v1beta.IListCachedContentsResponse, + ] + >; + listCachedContents( + request: protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest, + | protos.google.ai.generativelanguage.v1beta.IListCachedContentsResponse + | null + | undefined, + protos.google.ai.generativelanguage.v1beta.ICachedContent + > + ): void; + listCachedContents( + request: protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest, + callback: PaginationCallback< + protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest, + | protos.google.ai.generativelanguage.v1beta.IListCachedContentsResponse + | null + | undefined, + protos.google.ai.generativelanguage.v1beta.ICachedContent + > + ): void; + listCachedContents( + request?: protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest, + | protos.google.ai.generativelanguage.v1beta.IListCachedContentsResponse + | null + | undefined, + protos.google.ai.generativelanguage.v1beta.ICachedContent + >, + callback?: PaginationCallback< + protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest, + | protos.google.ai.generativelanguage.v1beta.IListCachedContentsResponse + | null + | undefined, + protos.google.ai.generativelanguage.v1beta.ICachedContent + > + ): Promise< + [ + protos.google.ai.generativelanguage.v1beta.ICachedContent[], + protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest | null, + protos.google.ai.generativelanguage.v1beta.IListCachedContentsResponse, + ] + > | 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 || {}; + this.initialize(); + return this.innerApiCalls.listCachedContents(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 {number} [request.pageSize] + * Optional. The maximum number of cached contents to return. The service may + * return fewer than this value. If unspecified, some default (under maximum) + * number of items will be returned. The maximum value is 1000; values above + * 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListCachedContents` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCachedContents` 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 protos.google.ai.generativelanguage.v1beta.CachedContent|CachedContent} 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 `listCachedContentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + listCachedContentsStream( + request?: protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listCachedContents']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCachedContents.createStream( + this.innerApiCalls.listCachedContents as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listCachedContents`, 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 {number} [request.pageSize] + * Optional. The maximum number of cached contents to return. The service may + * return fewer than this value. If unspecified, some default (under maximum) + * number of items will be returned. The maximum value is 1000; values above + * 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListCachedContents` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCachedContents` 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.ai.generativelanguage.v1beta.CachedContent|CachedContent}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/cache_service.list_cached_contents.js + * region_tag:generativelanguage_v1beta_generated_CacheService_ListCachedContents_async + */ + listCachedContentsAsync( + request?: protos.google.ai.generativelanguage.v1beta.IListCachedContentsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listCachedContents']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCachedContents.asyncIterate( + this.innerApiCalls['listCachedContents'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified cachedContent resource name string. + * + * @param {string} id + * @returns {string} Resource name string. + */ + cachedContentPath(id: string) { + return this.pathTemplates.cachedContentPathTemplate.render({ + id: id, + }); + } + + /** + * Parse the id from CachedContent resource. + * + * @param {string} cachedContentName + * A fully-qualified path representing CachedContent resource. + * @returns {string} A string representing the id. + */ + matchIdFromCachedContentName(cachedContentName: string) { + return this.pathTemplates.cachedContentPathTemplate.match(cachedContentName) + .id; + } + + /** + * Return a fully-qualified chunk resource name string. + * + * @param {string} corpus + * @param {string} document + * @param {string} chunk + * @returns {string} Resource name string. + */ + chunkPath(corpus: string, document: string, chunk: string) { + return this.pathTemplates.chunkPathTemplate.render({ + corpus: corpus, + document: document, + chunk: chunk, + }); + } + + /** + * Parse the corpus from Chunk resource. + * + * @param {string} chunkName + * A fully-qualified path representing Chunk resource. + * @returns {string} A string representing the corpus. + */ + matchCorpusFromChunkName(chunkName: string) { + return this.pathTemplates.chunkPathTemplate.match(chunkName).corpus; + } + + /** + * Parse the document from Chunk resource. + * + * @param {string} chunkName + * A fully-qualified path representing Chunk resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromChunkName(chunkName: string) { + return this.pathTemplates.chunkPathTemplate.match(chunkName).document; + } + + /** + * Parse the chunk from Chunk resource. + * + * @param {string} chunkName + * A fully-qualified path representing Chunk resource. + * @returns {string} A string representing the chunk. + */ + matchChunkFromChunkName(chunkName: string) { + return this.pathTemplates.chunkPathTemplate.match(chunkName).chunk; + } + + /** + * Return a fully-qualified corpus resource name string. + * + * @param {string} corpus + * @returns {string} Resource name string. + */ + corpusPath(corpus: string) { + return this.pathTemplates.corpusPathTemplate.render({ + corpus: corpus, + }); + } + + /** + * Parse the corpus from Corpus resource. + * + * @param {string} corpusName + * A fully-qualified path representing Corpus resource. + * @returns {string} A string representing the corpus. + */ + matchCorpusFromCorpusName(corpusName: string) { + return this.pathTemplates.corpusPathTemplate.match(corpusName).corpus; + } + + /** + * Return a fully-qualified corpusPermission resource name string. + * + * @param {string} corpus + * @param {string} permission + * @returns {string} Resource name string. + */ + corpusPermissionPath(corpus: string, permission: string) { + return this.pathTemplates.corpusPermissionPathTemplate.render({ + corpus: corpus, + permission: permission, + }); + } + + /** + * Parse the corpus from CorpusPermission resource. + * + * @param {string} corpusPermissionName + * A fully-qualified path representing corpus_permission resource. + * @returns {string} A string representing the corpus. + */ + matchCorpusFromCorpusPermissionName(corpusPermissionName: string) { + return this.pathTemplates.corpusPermissionPathTemplate.match( + corpusPermissionName + ).corpus; + } + + /** + * Parse the permission from CorpusPermission resource. + * + * @param {string} corpusPermissionName + * A fully-qualified path representing corpus_permission resource. + * @returns {string} A string representing the permission. + */ + matchPermissionFromCorpusPermissionName(corpusPermissionName: string) { + return this.pathTemplates.corpusPermissionPathTemplate.match( + corpusPermissionName + ).permission; + } + + /** + * Return a fully-qualified document resource name string. + * + * @param {string} corpus + * @param {string} document + * @returns {string} Resource name string. + */ + documentPath(corpus: string, document: string) { + return this.pathTemplates.documentPathTemplate.render({ + corpus: corpus, + document: document, + }); + } + + /** + * Parse the corpus from Document resource. + * + * @param {string} documentName + * A fully-qualified path representing Document resource. + * @returns {string} A string representing the corpus. + */ + matchCorpusFromDocumentName(documentName: string) { + return this.pathTemplates.documentPathTemplate.match(documentName).corpus; + } + + /** + * Parse the document from Document resource. + * + * @param {string} documentName + * A fully-qualified path representing Document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromDocumentName(documentName: string) { + return this.pathTemplates.documentPathTemplate.match(documentName).document; + } + + /** + * Return a fully-qualified file resource name string. + * + * @param {string} file + * @returns {string} Resource name string. + */ + filePath(file: string) { + return this.pathTemplates.filePathTemplate.render({ + file: file, + }); + } + + /** + * Parse the file from File resource. + * + * @param {string} fileName + * A fully-qualified path representing File resource. + * @returns {string} A string representing the file. + */ + matchFileFromFileName(fileName: string) { + return this.pathTemplates.filePathTemplate.match(fileName).file; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(model: string) { + return this.pathTemplates.modelPathTemplate.render({ + model: model, + }); + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified tunedModel resource name string. + * + * @param {string} tuned_model + * @returns {string} Resource name string. + */ + tunedModelPath(tunedModel: string) { + return this.pathTemplates.tunedModelPathTemplate.render({ + tuned_model: tunedModel, + }); + } + + /** + * Parse the tuned_model from TunedModel resource. + * + * @param {string} tunedModelName + * A fully-qualified path representing TunedModel resource. + * @returns {string} A string representing the tuned_model. + */ + matchTunedModelFromTunedModelName(tunedModelName: string) { + return this.pathTemplates.tunedModelPathTemplate.match(tunedModelName) + .tuned_model; + } + + /** + * Return a fully-qualified tunedModelPermission resource name string. + * + * @param {string} tuned_model + * @param {string} permission + * @returns {string} Resource name string. + */ + tunedModelPermissionPath(tunedModel: string, permission: string) { + return this.pathTemplates.tunedModelPermissionPathTemplate.render({ + tuned_model: tunedModel, + permission: permission, + }); + } + + /** + * Parse the tuned_model from TunedModelPermission resource. + * + * @param {string} tunedModelPermissionName + * A fully-qualified path representing tuned_model_permission resource. + * @returns {string} A string representing the tuned_model. + */ + matchTunedModelFromTunedModelPermissionName( + tunedModelPermissionName: string + ) { + return this.pathTemplates.tunedModelPermissionPathTemplate.match( + tunedModelPermissionName + ).tuned_model; + } + + /** + * Parse the permission from TunedModelPermission resource. + * + * @param {string} tunedModelPermissionName + * A fully-qualified path representing tuned_model_permission resource. + * @returns {string} A string representing the permission. + */ + matchPermissionFromTunedModelPermissionName( + tunedModelPermissionName: string + ) { + return this.pathTemplates.tunedModelPermissionPathTemplate.match( + tunedModelPermissionName + ).permission; + } + + /** + * 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.cacheServiceStub && !this._terminated) { + return this.cacheServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-ai-generativelanguage/src/v1beta/cache_service_client_config.json b/packages/google-ai-generativelanguage/src/v1beta/cache_service_client_config.json new file mode 100644 index 00000000000..1a57fd1ea86 --- /dev/null +++ b/packages/google-ai-generativelanguage/src/v1beta/cache_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.ai.generativelanguage.v1beta.CacheService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "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 + } + }, + "methods": { + "ListCachedContents": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateCachedContent": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetCachedContent": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateCachedContent": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteCachedContent": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-ai-generativelanguage/src/v1beta/cache_service_proto_list.json b/packages/google-ai-generativelanguage/src/v1beta/cache_service_proto_list.json new file mode 100644 index 00000000000..16db08ec00a --- /dev/null +++ b/packages/google-ai-generativelanguage/src/v1beta/cache_service_proto_list.json @@ -0,0 +1,19 @@ +[ + "../../protos/google/ai/generativelanguage/v1beta/cache_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/cached_content.proto", + "../../protos/google/ai/generativelanguage/v1beta/citation.proto", + "../../protos/google/ai/generativelanguage/v1beta/content.proto", + "../../protos/google/ai/generativelanguage/v1beta/discuss_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/file.proto", + "../../protos/google/ai/generativelanguage/v1beta/file_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/generative_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/model.proto", + "../../protos/google/ai/generativelanguage/v1beta/model_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/permission.proto", + "../../protos/google/ai/generativelanguage/v1beta/permission_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/retriever.proto", + "../../protos/google/ai/generativelanguage/v1beta/retriever_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/safety.proto", + "../../protos/google/ai/generativelanguage/v1beta/text_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/tuned_model.proto" +] diff --git a/packages/google-ai-generativelanguage/src/v1beta/discuss_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/discuss_service_client.ts index 69cd08b0342..6585f4e09f8 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/discuss_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/discuss_service_client.ts @@ -200,6 +200,9 @@ export class DiscussServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { + cachedContentPathTemplate: new this._gaxModule.PathTemplate( + 'cachedContents/{id}' + ), chunkPathTemplate: new this._gaxModule.PathTemplate( 'corpora/{corpus}/documents/{document}/chunks/{chunk}' ), @@ -622,6 +625,30 @@ export class DiscussServiceClient { // -- Path templates -- // -------------------- + /** + * Return a fully-qualified cachedContent resource name string. + * + * @param {string} id + * @returns {string} Resource name string. + */ + cachedContentPath(id: string) { + return this.pathTemplates.cachedContentPathTemplate.render({ + id: id, + }); + } + + /** + * Parse the id from CachedContent resource. + * + * @param {string} cachedContentName + * A fully-qualified path representing CachedContent resource. + * @returns {string} A string representing the id. + */ + matchIdFromCachedContentName(cachedContentName: string) { + return this.pathTemplates.cachedContentPathTemplate.match(cachedContentName) + .id; + } + /** * Return a fully-qualified chunk resource name string. * diff --git a/packages/google-ai-generativelanguage/src/v1beta/discuss_service_proto_list.json b/packages/google-ai-generativelanguage/src/v1beta/discuss_service_proto_list.json index 022d89ef82c..16db08ec00a 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/discuss_service_proto_list.json +++ b/packages/google-ai-generativelanguage/src/v1beta/discuss_service_proto_list.json @@ -1,4 +1,6 @@ [ + "../../protos/google/ai/generativelanguage/v1beta/cache_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/cached_content.proto", "../../protos/google/ai/generativelanguage/v1beta/citation.proto", "../../protos/google/ai/generativelanguage/v1beta/content.proto", "../../protos/google/ai/generativelanguage/v1beta/discuss_service.proto", diff --git a/packages/google-ai-generativelanguage/src/v1beta/file_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/file_service_client.ts index 30788a52d40..abd49249b24 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/file_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/file_service_client.ts @@ -199,6 +199,9 @@ export class FileServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { + cachedContentPathTemplate: new this._gaxModule.PathTemplate( + 'cachedContents/{id}' + ), chunkPathTemplate: new this._gaxModule.PathTemplate( 'corpora/{corpus}/documents/{document}/chunks/{chunk}' ), @@ -842,6 +845,30 @@ export class FileServiceClient { // -- Path templates -- // -------------------- + /** + * Return a fully-qualified cachedContent resource name string. + * + * @param {string} id + * @returns {string} Resource name string. + */ + cachedContentPath(id: string) { + return this.pathTemplates.cachedContentPathTemplate.render({ + id: id, + }); + } + + /** + * Parse the id from CachedContent resource. + * + * @param {string} cachedContentName + * A fully-qualified path representing CachedContent resource. + * @returns {string} A string representing the id. + */ + matchIdFromCachedContentName(cachedContentName: string) { + return this.pathTemplates.cachedContentPathTemplate.match(cachedContentName) + .id; + } + /** * Return a fully-qualified chunk resource name string. * diff --git a/packages/google-ai-generativelanguage/src/v1beta/file_service_proto_list.json b/packages/google-ai-generativelanguage/src/v1beta/file_service_proto_list.json index 022d89ef82c..16db08ec00a 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/file_service_proto_list.json +++ b/packages/google-ai-generativelanguage/src/v1beta/file_service_proto_list.json @@ -1,4 +1,6 @@ [ + "../../protos/google/ai/generativelanguage/v1beta/cache_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/cached_content.proto", "../../protos/google/ai/generativelanguage/v1beta/citation.proto", "../../protos/google/ai/generativelanguage/v1beta/content.proto", "../../protos/google/ai/generativelanguage/v1beta/discuss_service.proto", diff --git a/packages/google-ai-generativelanguage/src/v1beta/gapic_metadata.json b/packages/google-ai-generativelanguage/src/v1beta/gapic_metadata.json index 2ca685798db..8a898aa047f 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/gapic_metadata.json +++ b/packages/google-ai-generativelanguage/src/v1beta/gapic_metadata.json @@ -5,6 +5,74 @@ "protoPackage": "google.ai.generativelanguage.v1beta", "libraryPackage": "@google-ai/generativelanguage", "services": { + "CacheService": { + "clients": { + "grpc": { + "libraryClient": "CacheServiceClient", + "rpcs": { + "CreateCachedContent": { + "methods": [ + "createCachedContent" + ] + }, + "GetCachedContent": { + "methods": [ + "getCachedContent" + ] + }, + "UpdateCachedContent": { + "methods": [ + "updateCachedContent" + ] + }, + "DeleteCachedContent": { + "methods": [ + "deleteCachedContent" + ] + }, + "ListCachedContents": { + "methods": [ + "listCachedContents", + "listCachedContentsStream", + "listCachedContentsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CacheServiceClient", + "rpcs": { + "CreateCachedContent": { + "methods": [ + "createCachedContent" + ] + }, + "GetCachedContent": { + "methods": [ + "getCachedContent" + ] + }, + "UpdateCachedContent": { + "methods": [ + "updateCachedContent" + ] + }, + "DeleteCachedContent": { + "methods": [ + "deleteCachedContent" + ] + }, + "ListCachedContents": { + "methods": [ + "listCachedContents", + "listCachedContentsStream", + "listCachedContentsAsync" + ] + } + } + } + } + }, "DiscussService": { "clients": { "grpc": { diff --git a/packages/google-ai-generativelanguage/src/v1beta/generative_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/generative_service_client.ts index f7638d8d042..adc8f5c8a94 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/generative_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/generative_service_client.ts @@ -198,6 +198,9 @@ export class GenerativeServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { + cachedContentPathTemplate: new this._gaxModule.PathTemplate( + 'cachedContents/{id}' + ), chunkPathTemplate: new this._gaxModule.PathTemplate( 'corpora/{corpus}/documents/{document}/chunks/{chunk}' ), @@ -460,6 +463,11 @@ export class GenerativeServiceClient { * HARM_CATEGORY_HARASSMENT are supported. * @param {google.ai.generativelanguage.v1beta.GenerationConfig} [request.generationConfig] * Optional. Configuration options for model generation and outputs. + * @param {string} [request.cachedContent] + * Optional. The name of the cached content used as context to serve the + * prediction. Note: only used in explicit caching, where users can have + * control over caching (e.g. what content to cache) and enjoy guaranteed cost + * savings. Format: `cachedContents/{cachedContent}` * @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. @@ -1060,6 +1068,11 @@ export class GenerativeServiceClient { * HARM_CATEGORY_HARASSMENT are supported. * @param {google.ai.generativelanguage.v1beta.GenerationConfig} [request.generationConfig] * Optional. Configuration options for model generation and outputs. + * @param {string} [request.cachedContent] + * Optional. The name of the cached content used as context to serve the + * prediction. Note: only used in explicit caching, where users can have + * control over caching (e.g. what content to cache) and enjoy guaranteed cost + * savings. Format: `cachedContents/{cachedContent}` * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1089,6 +1102,30 @@ export class GenerativeServiceClient { // -- Path templates -- // -------------------- + /** + * Return a fully-qualified cachedContent resource name string. + * + * @param {string} id + * @returns {string} Resource name string. + */ + cachedContentPath(id: string) { + return this.pathTemplates.cachedContentPathTemplate.render({ + id: id, + }); + } + + /** + * Parse the id from CachedContent resource. + * + * @param {string} cachedContentName + * A fully-qualified path representing CachedContent resource. + * @returns {string} A string representing the id. + */ + matchIdFromCachedContentName(cachedContentName: string) { + return this.pathTemplates.cachedContentPathTemplate.match(cachedContentName) + .id; + } + /** * Return a fully-qualified chunk resource name string. * diff --git a/packages/google-ai-generativelanguage/src/v1beta/generative_service_proto_list.json b/packages/google-ai-generativelanguage/src/v1beta/generative_service_proto_list.json index 022d89ef82c..16db08ec00a 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/generative_service_proto_list.json +++ b/packages/google-ai-generativelanguage/src/v1beta/generative_service_proto_list.json @@ -1,4 +1,6 @@ [ + "../../protos/google/ai/generativelanguage/v1beta/cache_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/cached_content.proto", "../../protos/google/ai/generativelanguage/v1beta/citation.proto", "../../protos/google/ai/generativelanguage/v1beta/content.proto", "../../protos/google/ai/generativelanguage/v1beta/discuss_service.proto", diff --git a/packages/google-ai-generativelanguage/src/v1beta/index.ts b/packages/google-ai-generativelanguage/src/v1beta/index.ts index 5fd52512a63..ce43394f242 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/index.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/index.ts @@ -16,6 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** +export {CacheServiceClient} from './cache_service_client'; export {DiscussServiceClient} from './discuss_service_client'; export {FileServiceClient} from './file_service_client'; export {GenerativeServiceClient} from './generative_service_client'; diff --git a/packages/google-ai-generativelanguage/src/v1beta/model_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/model_service_client.ts index 34fa9553064..9de69ffaafc 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/model_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/model_service_client.ts @@ -202,6 +202,9 @@ export class ModelServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { + cachedContentPathTemplate: new this._gaxModule.PathTemplate( + 'cachedContents/{id}' + ), chunkPathTemplate: new this._gaxModule.PathTemplate( 'corpora/{corpus}/documents/{document}/chunks/{chunk}' ), @@ -1600,6 +1603,30 @@ export class ModelServiceClient { // -- Path templates -- // -------------------- + /** + * Return a fully-qualified cachedContent resource name string. + * + * @param {string} id + * @returns {string} Resource name string. + */ + cachedContentPath(id: string) { + return this.pathTemplates.cachedContentPathTemplate.render({ + id: id, + }); + } + + /** + * Parse the id from CachedContent resource. + * + * @param {string} cachedContentName + * A fully-qualified path representing CachedContent resource. + * @returns {string} A string representing the id. + */ + matchIdFromCachedContentName(cachedContentName: string) { + return this.pathTemplates.cachedContentPathTemplate.match(cachedContentName) + .id; + } + /** * Return a fully-qualified chunk resource name string. * diff --git a/packages/google-ai-generativelanguage/src/v1beta/model_service_proto_list.json b/packages/google-ai-generativelanguage/src/v1beta/model_service_proto_list.json index 022d89ef82c..16db08ec00a 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/model_service_proto_list.json +++ b/packages/google-ai-generativelanguage/src/v1beta/model_service_proto_list.json @@ -1,4 +1,6 @@ [ + "../../protos/google/ai/generativelanguage/v1beta/cache_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/cached_content.proto", "../../protos/google/ai/generativelanguage/v1beta/citation.proto", "../../protos/google/ai/generativelanguage/v1beta/content.proto", "../../protos/google/ai/generativelanguage/v1beta/discuss_service.proto", diff --git a/packages/google-ai-generativelanguage/src/v1beta/permission_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/permission_service_client.ts index a6c825b5f91..c4ab828ea2b 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/permission_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/permission_service_client.ts @@ -199,6 +199,9 @@ export class PermissionServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { + cachedContentPathTemplate: new this._gaxModule.PathTemplate( + 'cachedContents/{id}' + ), chunkPathTemplate: new this._gaxModule.PathTemplate( 'corpora/{corpus}/documents/{document}/chunks/{chunk}' ), @@ -1138,6 +1141,30 @@ export class PermissionServiceClient { // -- Path templates -- // -------------------- + /** + * Return a fully-qualified cachedContent resource name string. + * + * @param {string} id + * @returns {string} Resource name string. + */ + cachedContentPath(id: string) { + return this.pathTemplates.cachedContentPathTemplate.render({ + id: id, + }); + } + + /** + * Parse the id from CachedContent resource. + * + * @param {string} cachedContentName + * A fully-qualified path representing CachedContent resource. + * @returns {string} A string representing the id. + */ + matchIdFromCachedContentName(cachedContentName: string) { + return this.pathTemplates.cachedContentPathTemplate.match(cachedContentName) + .id; + } + /** * Return a fully-qualified chunk resource name string. * diff --git a/packages/google-ai-generativelanguage/src/v1beta/permission_service_proto_list.json b/packages/google-ai-generativelanguage/src/v1beta/permission_service_proto_list.json index 022d89ef82c..16db08ec00a 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/permission_service_proto_list.json +++ b/packages/google-ai-generativelanguage/src/v1beta/permission_service_proto_list.json @@ -1,4 +1,6 @@ [ + "../../protos/google/ai/generativelanguage/v1beta/cache_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/cached_content.proto", "../../protos/google/ai/generativelanguage/v1beta/citation.proto", "../../protos/google/ai/generativelanguage/v1beta/content.proto", "../../protos/google/ai/generativelanguage/v1beta/discuss_service.proto", diff --git a/packages/google-ai-generativelanguage/src/v1beta/retriever_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/retriever_service_client.ts index 40cff0f407a..b4ec9ba5060 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/retriever_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/retriever_service_client.ts @@ -199,6 +199,9 @@ export class RetrieverServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { + cachedContentPathTemplate: new this._gaxModule.PathTemplate( + 'cachedContents/{id}' + ), chunkPathTemplate: new this._gaxModule.PathTemplate( 'corpora/{corpus}/documents/{document}/chunks/{chunk}' ), @@ -2812,6 +2815,30 @@ export class RetrieverServiceClient { // -- Path templates -- // -------------------- + /** + * Return a fully-qualified cachedContent resource name string. + * + * @param {string} id + * @returns {string} Resource name string. + */ + cachedContentPath(id: string) { + return this.pathTemplates.cachedContentPathTemplate.render({ + id: id, + }); + } + + /** + * Parse the id from CachedContent resource. + * + * @param {string} cachedContentName + * A fully-qualified path representing CachedContent resource. + * @returns {string} A string representing the id. + */ + matchIdFromCachedContentName(cachedContentName: string) { + return this.pathTemplates.cachedContentPathTemplate.match(cachedContentName) + .id; + } + /** * Return a fully-qualified chunk resource name string. * diff --git a/packages/google-ai-generativelanguage/src/v1beta/retriever_service_proto_list.json b/packages/google-ai-generativelanguage/src/v1beta/retriever_service_proto_list.json index 022d89ef82c..16db08ec00a 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/retriever_service_proto_list.json +++ b/packages/google-ai-generativelanguage/src/v1beta/retriever_service_proto_list.json @@ -1,4 +1,6 @@ [ + "../../protos/google/ai/generativelanguage/v1beta/cache_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/cached_content.proto", "../../protos/google/ai/generativelanguage/v1beta/citation.proto", "../../protos/google/ai/generativelanguage/v1beta/content.proto", "../../protos/google/ai/generativelanguage/v1beta/discuss_service.proto", diff --git a/packages/google-ai-generativelanguage/src/v1beta/text_service_client.ts b/packages/google-ai-generativelanguage/src/v1beta/text_service_client.ts index 57fa1f47303..2600061389a 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/text_service_client.ts +++ b/packages/google-ai-generativelanguage/src/v1beta/text_service_client.ts @@ -200,6 +200,9 @@ export class TextServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { + cachedContentPathTemplate: new this._gaxModule.PathTemplate( + 'cachedContents/{id}' + ), chunkPathTemplate: new this._gaxModule.PathTemplate( 'corpora/{corpus}/documents/{document}/chunks/{chunk}' ), @@ -861,6 +864,30 @@ export class TextServiceClient { // -- Path templates -- // -------------------- + /** + * Return a fully-qualified cachedContent resource name string. + * + * @param {string} id + * @returns {string} Resource name string. + */ + cachedContentPath(id: string) { + return this.pathTemplates.cachedContentPathTemplate.render({ + id: id, + }); + } + + /** + * Parse the id from CachedContent resource. + * + * @param {string} cachedContentName + * A fully-qualified path representing CachedContent resource. + * @returns {string} A string representing the id. + */ + matchIdFromCachedContentName(cachedContentName: string) { + return this.pathTemplates.cachedContentPathTemplate.match(cachedContentName) + .id; + } + /** * Return a fully-qualified chunk resource name string. * diff --git a/packages/google-ai-generativelanguage/src/v1beta/text_service_proto_list.json b/packages/google-ai-generativelanguage/src/v1beta/text_service_proto_list.json index 022d89ef82c..16db08ec00a 100644 --- a/packages/google-ai-generativelanguage/src/v1beta/text_service_proto_list.json +++ b/packages/google-ai-generativelanguage/src/v1beta/text_service_proto_list.json @@ -1,4 +1,6 @@ [ + "../../protos/google/ai/generativelanguage/v1beta/cache_service.proto", + "../../protos/google/ai/generativelanguage/v1beta/cached_content.proto", "../../protos/google/ai/generativelanguage/v1beta/citation.proto", "../../protos/google/ai/generativelanguage/v1beta/content.proto", "../../protos/google/ai/generativelanguage/v1beta/discuss_service.proto", diff --git a/packages/google-ai-generativelanguage/system-test/fixtures/sample/src/index.js b/packages/google-ai-generativelanguage/system-test/fixtures/sample/src/index.js index 8a2ae0771a6..80fbd1f1d18 100644 --- a/packages/google-ai-generativelanguage/system-test/fixtures/sample/src/index.js +++ b/packages/google-ai-generativelanguage/system-test/fixtures/sample/src/index.js @@ -20,6 +20,7 @@ const generativelanguage = require('@google-ai/generativelanguage'); function main() { + const cacheServiceClient = new generativelanguage.CacheServiceClient(); const discussServiceClient = new generativelanguage.DiscussServiceClient(); const fileServiceClient = new generativelanguage.FileServiceClient(); const generativeServiceClient = diff --git a/packages/google-ai-generativelanguage/system-test/fixtures/sample/src/index.ts b/packages/google-ai-generativelanguage/system-test/fixtures/sample/src/index.ts index 7ebb2af3725..db13e2772f1 100644 --- a/packages/google-ai-generativelanguage/system-test/fixtures/sample/src/index.ts +++ b/packages/google-ai-generativelanguage/system-test/fixtures/sample/src/index.ts @@ -17,6 +17,7 @@ // ** All changes to this file may be overwritten. ** import { + CacheServiceClient, DiscussServiceClient, FileServiceClient, GenerativeServiceClient, @@ -27,6 +28,9 @@ import { } from '@google-ai/generativelanguage'; // check that the client class type name can be used +function doStuffWithCacheServiceClient(client: CacheServiceClient) { + client.close(); +} function doStuffWithDiscussServiceClient(client: DiscussServiceClient) { client.close(); } @@ -50,6 +54,9 @@ function doStuffWithTextServiceClient(client: TextServiceClient) { } function main() { + // check that the client instance can be created + const cacheServiceClient = new CacheServiceClient(); + doStuffWithCacheServiceClient(cacheServiceClient); // check that the client instance can be created const discussServiceClient = new DiscussServiceClient(); doStuffWithDiscussServiceClient(discussServiceClient); diff --git a/packages/google-ai-generativelanguage/test/gapic_cache_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_cache_service_v1beta.ts new file mode 100644 index 00000000000..a3123a40fa4 --- /dev/null +++ b/packages/google-ai-generativelanguage/test/gapic_cache_service_v1beta.ts @@ -0,0 +1,1455 @@ +// Copyright 2024 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 cacheserviceModule 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.CacheServiceClient', () => { + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + cacheserviceModule.v1beta.CacheServiceClient.servicePath; + assert.strictEqual(servicePath, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + cacheserviceModule.v1beta.CacheServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'generativelanguage.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + }); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new cacheserviceModule.v1beta.CacheServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'generativelanguage.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'generativelanguage.configured.example.com' + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new cacheserviceModule.v1beta.CacheServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); + }); + + it('has port', () => { + const port = cacheserviceModule.v1beta.CacheServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cacheServiceStub, undefined); + await client.initialize(); + assert(client.cacheServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cacheServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cacheServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + 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 cacheserviceModule.v1beta.CacheServiceClient({ + 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('createCachedContent', () => { + it('invokes createCachedContent without error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CreateCachedContentRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ); + client.innerApiCalls.createCachedContent = + stubSimpleCall(expectedResponse); + const [response] = await client.createCachedContent(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createCachedContent without error using callback', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CreateCachedContentRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ); + client.innerApiCalls.createCachedContent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCachedContent( + request, + ( + err?: Error | null, + result?: protos.google.ai.generativelanguage.v1beta.ICachedContent | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createCachedContent with error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CreateCachedContentRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createCachedContent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createCachedContent(request), expectedError); + }); + + it('invokes createCachedContent with closed client', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CreateCachedContentRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createCachedContent(request), expectedError); + }); + }); + + describe('getCachedContent', () => { + it('invokes getCachedContent without error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.GetCachedContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.GetCachedContentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ); + client.innerApiCalls.getCachedContent = stubSimpleCall(expectedResponse); + const [response] = await client.getCachedContent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCachedContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCachedContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCachedContent without error using callback', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.GetCachedContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.GetCachedContentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ); + client.innerApiCalls.getCachedContent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCachedContent( + request, + ( + err?: Error | null, + result?: protos.google.ai.generativelanguage.v1beta.ICachedContent | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCachedContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCachedContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCachedContent with error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.GetCachedContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.GetCachedContentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCachedContent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getCachedContent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCachedContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCachedContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCachedContent with closed client', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.GetCachedContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.GetCachedContentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCachedContent(request), expectedError); + }); + }); + + describe('updateCachedContent', () => { + it('invokes updateCachedContent without error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest() + ); + request.cachedContent ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest', + ['cachedContent', 'name'] + ); + request.cachedContent.name = defaultValue1; + const expectedHeaderRequestParams = `cached_content.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ); + client.innerApiCalls.updateCachedContent = + stubSimpleCall(expectedResponse); + const [response] = await client.updateCachedContent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCachedContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCachedContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCachedContent without error using callback', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest() + ); + request.cachedContent ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest', + ['cachedContent', 'name'] + ); + request.cachedContent.name = defaultValue1; + const expectedHeaderRequestParams = `cached_content.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ); + client.innerApiCalls.updateCachedContent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCachedContent( + request, + ( + err?: Error | null, + result?: protos.google.ai.generativelanguage.v1beta.ICachedContent | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCachedContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCachedContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCachedContent with error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest() + ); + request.cachedContent ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest', + ['cachedContent', 'name'] + ); + request.cachedContent.name = defaultValue1; + const expectedHeaderRequestParams = `cached_content.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCachedContent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateCachedContent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCachedContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCachedContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCachedContent with closed client', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest() + ); + request.cachedContent ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.UpdateCachedContentRequest', + ['cachedContent', 'name'] + ); + request.cachedContent.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCachedContent(request), expectedError); + }); + }); + + describe('deleteCachedContent', () => { + it('invokes deleteCachedContent without error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteCachedContent = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteCachedContent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCachedContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCachedContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCachedContent without error using callback', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteCachedContent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCachedContent( + 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.deleteCachedContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCachedContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCachedContent with error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCachedContent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteCachedContent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCachedContent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCachedContent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteCachedContent with closed client', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.ai.generativelanguage.v1beta.DeleteCachedContentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteCachedContent(request), expectedError); + }); + }); + + describe('listCachedContents', () => { + it('invokes listCachedContents without error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.ListCachedContentsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + ]; + client.innerApiCalls.listCachedContents = + stubSimpleCall(expectedResponse); + const [response] = await client.listCachedContents(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listCachedContents without error using callback', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.ListCachedContentsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + ]; + client.innerApiCalls.listCachedContents = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCachedContents( + request, + ( + err?: Error | null, + result?: + | protos.google.ai.generativelanguage.v1beta.ICachedContent[] + | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listCachedContents with error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.ListCachedContentsRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listCachedContents = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listCachedContents(request), expectedError); + }); + + it('invokes listCachedContentsStream without error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.ListCachedContentsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + ]; + client.descriptors.page.listCachedContents.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCachedContentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.ai.generativelanguage.v1beta.CachedContent[] = + []; + stream.on( + 'data', + ( + response: protos.google.ai.generativelanguage.v1beta.CachedContent + ) => { + 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.listCachedContents.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCachedContents, request) + ); + }); + + it('invokes listCachedContentsStream with error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.ListCachedContentsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listCachedContents.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCachedContentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.ai.generativelanguage.v1beta.CachedContent[] = + []; + stream.on( + 'data', + ( + response: protos.google.ai.generativelanguage.v1beta.CachedContent + ) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCachedContents.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCachedContents, request) + ); + }); + + it('uses async iteration with listCachedContents without error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.ListCachedContentsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.CachedContent() + ), + ]; + client.descriptors.page.listCachedContents.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.ai.generativelanguage.v1beta.ICachedContent[] = + []; + const iterable = client.listCachedContentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCachedContents.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + + it('uses async iteration with listCachedContents with error', async () => { + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.ai.generativelanguage.v1beta.ListCachedContentsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listCachedContents.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCachedContentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.ai.generativelanguage.v1beta.ICachedContent[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCachedContents.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('cachedContent', () => { + const fakePath = '/rendered/path/cachedContent'; + const expectedParameters = { + id: 'idValue', + }; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cachedContentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cachedContentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cachedContentPath', () => { + const result = client.cachedContentPath('idValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cachedContentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchIdFromCachedContentName', () => { + const result = client.matchIdFromCachedContentName(fakePath); + assert.strictEqual(result, 'idValue'); + assert( + (client.pathTemplates.cachedContentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('chunk', () => { + const fakePath = '/rendered/path/chunk'; + const expectedParameters = { + corpus: 'corpusValue', + document: 'documentValue', + chunk: 'chunkValue', + }; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.chunkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.chunkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('chunkPath', () => { + const result = client.chunkPath( + 'corpusValue', + 'documentValue', + 'chunkValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.chunkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchCorpusFromChunkName', () => { + const result = client.matchCorpusFromChunkName(fakePath); + assert.strictEqual(result, 'corpusValue'); + assert( + (client.pathTemplates.chunkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchDocumentFromChunkName', () => { + const result = client.matchDocumentFromChunkName(fakePath); + assert.strictEqual(result, 'documentValue'); + assert( + (client.pathTemplates.chunkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchChunkFromChunkName', () => { + const result = client.matchChunkFromChunkName(fakePath); + assert.strictEqual(result, 'chunkValue'); + assert( + (client.pathTemplates.chunkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('corpus', () => { + const fakePath = '/rendered/path/corpus'; + const expectedParameters = { + corpus: 'corpusValue', + }; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.corpusPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.corpusPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('corpusPath', () => { + const result = client.corpusPath('corpusValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.corpusPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchCorpusFromCorpusName', () => { + const result = client.matchCorpusFromCorpusName(fakePath); + assert.strictEqual(result, 'corpusValue'); + assert( + (client.pathTemplates.corpusPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('corpusPermission', () => { + const fakePath = '/rendered/path/corpusPermission'; + const expectedParameters = { + corpus: 'corpusValue', + permission: 'permissionValue', + }; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.corpusPermissionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.corpusPermissionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('corpusPermissionPath', () => { + const result = client.corpusPermissionPath( + 'corpusValue', + 'permissionValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.corpusPermissionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchCorpusFromCorpusPermissionName', () => { + const result = client.matchCorpusFromCorpusPermissionName(fakePath); + assert.strictEqual(result, 'corpusValue'); + assert( + (client.pathTemplates.corpusPermissionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchPermissionFromCorpusPermissionName', () => { + const result = client.matchPermissionFromCorpusPermissionName(fakePath); + assert.strictEqual(result, 'permissionValue'); + assert( + (client.pathTemplates.corpusPermissionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('document', () => { + const fakePath = '/rendered/path/document'; + const expectedParameters = { + corpus: 'corpusValue', + document: 'documentValue', + }; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.documentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('documentPath', () => { + const result = client.documentPath('corpusValue', 'documentValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.documentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchCorpusFromDocumentName', () => { + const result = client.matchCorpusFromDocumentName(fakePath); + assert.strictEqual(result, 'corpusValue'); + assert( + (client.pathTemplates.documentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchDocumentFromDocumentName', () => { + const result = client.matchDocumentFromDocumentName(fakePath); + assert.strictEqual(result, 'documentValue'); + assert( + (client.pathTemplates.documentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('file', () => { + const fakePath = '/rendered/path/file'; + const expectedParameters = { + file: 'fileValue', + }; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.filePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.filePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('filePath', () => { + const result = client.filePath('fileValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.filePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchFileFromFileName', () => { + const result = client.matchFileFromFileName(fakePath); + assert.strictEqual(result, 'fileValue'); + assert( + (client.pathTemplates.filePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + model: 'modelValue', + }; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath('modelValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('tunedModel', () => { + const fakePath = '/rendered/path/tunedModel'; + const expectedParameters = { + tuned_model: 'tunedModelValue', + }; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tunedModelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tunedModelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tunedModelPath', () => { + const result = client.tunedModelPath('tunedModelValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tunedModelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchTunedModelFromTunedModelName', () => { + const result = client.matchTunedModelFromTunedModelName(fakePath); + assert.strictEqual(result, 'tunedModelValue'); + assert( + (client.pathTemplates.tunedModelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('tunedModelPermission', () => { + const fakePath = '/rendered/path/tunedModelPermission'; + const expectedParameters = { + tuned_model: 'tunedModelValue', + permission: 'permissionValue', + }; + const client = new cacheserviceModule.v1beta.CacheServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tunedModelPermissionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tunedModelPermissionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tunedModelPermissionPath', () => { + const result = client.tunedModelPermissionPath( + 'tunedModelValue', + 'permissionValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.tunedModelPermissionPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchTunedModelFromTunedModelPermissionName', () => { + const result = + client.matchTunedModelFromTunedModelPermissionName(fakePath); + assert.strictEqual(result, 'tunedModelValue'); + assert( + ( + client.pathTemplates.tunedModelPermissionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchPermissionFromTunedModelPermissionName', () => { + const result = + client.matchPermissionFromTunedModelPermissionName(fakePath); + assert.strictEqual(result, 'permissionValue'); + assert( + ( + client.pathTemplates.tunedModelPermissionPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta.ts index 58be95399c4..094d690a272 100644 --- a/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_discuss_service_v1beta.ts @@ -507,6 +507,44 @@ describe('v1beta.DiscussServiceClient', () => { }); describe('Path templates', () => { + describe('cachedContent', () => { + const fakePath = '/rendered/path/cachedContent'; + const expectedParameters = { + id: 'idValue', + }; + const client = new discussserviceModule.v1beta.DiscussServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cachedContentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cachedContentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cachedContentPath', () => { + const result = client.cachedContentPath('idValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cachedContentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchIdFromCachedContentName', () => { + const result = client.matchIdFromCachedContentName(fakePath); + assert.strictEqual(result, 'idValue'); + assert( + (client.pathTemplates.cachedContentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('chunk', () => { const fakePath = '/rendered/path/chunk'; const expectedParameters = { diff --git a/packages/google-ai-generativelanguage/test/gapic_file_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_file_service_v1beta.ts index 24e5390d9cc..0fc60e02f99 100644 --- a/packages/google-ai-generativelanguage/test/gapic_file_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_file_service_v1beta.ts @@ -880,6 +880,44 @@ describe('v1beta.FileServiceClient', () => { }); describe('Path templates', () => { + describe('cachedContent', () => { + const fakePath = '/rendered/path/cachedContent'; + const expectedParameters = { + id: 'idValue', + }; + const client = new fileserviceModule.v1beta.FileServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cachedContentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cachedContentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cachedContentPath', () => { + const result = client.cachedContentPath('idValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cachedContentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchIdFromCachedContentName', () => { + const result = client.matchIdFromCachedContentName(fakePath); + assert.strictEqual(result, 'idValue'); + assert( + (client.pathTemplates.cachedContentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('chunk', () => { const fakePath = '/rendered/path/chunk'; const expectedParameters = { diff --git a/packages/google-ai-generativelanguage/test/gapic_generative_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_generative_service_v1beta.ts index 1f8e2c88586..6d71f0a89bc 100644 --- a/packages/google-ai-generativelanguage/test/gapic_generative_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_generative_service_v1beta.ts @@ -1164,6 +1164,46 @@ describe('v1beta.GenerativeServiceClient', () => { }); describe('Path templates', () => { + describe('cachedContent', () => { + const fakePath = '/rendered/path/cachedContent'; + const expectedParameters = { + id: 'idValue', + }; + const client = new generativeserviceModule.v1beta.GenerativeServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.cachedContentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cachedContentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cachedContentPath', () => { + const result = client.cachedContentPath('idValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cachedContentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchIdFromCachedContentName', () => { + const result = client.matchIdFromCachedContentName(fakePath); + assert.strictEqual(result, 'idValue'); + assert( + (client.pathTemplates.cachedContentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('chunk', () => { const fakePath = '/rendered/path/chunk'; const expectedParameters = { diff --git a/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta.ts index bbc09c2b24c..132ada2d2cd 100644 --- a/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_model_service_v1beta.ts @@ -1780,6 +1780,44 @@ describe('v1beta.ModelServiceClient', () => { }); describe('Path templates', () => { + describe('cachedContent', () => { + const fakePath = '/rendered/path/cachedContent'; + const expectedParameters = { + id: 'idValue', + }; + const client = new modelserviceModule.v1beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cachedContentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cachedContentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cachedContentPath', () => { + const result = client.cachedContentPath('idValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cachedContentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchIdFromCachedContentName', () => { + const result = client.matchIdFromCachedContentName(fakePath); + assert.strictEqual(result, 'idValue'); + assert( + (client.pathTemplates.cachedContentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('chunk', () => { const fakePath = '/rendered/path/chunk'; const expectedParameters = { diff --git a/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta.ts index c4984672222..65329ffc45d 100644 --- a/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_permission_service_v1beta.ts @@ -1365,6 +1365,46 @@ describe('v1beta.PermissionServiceClient', () => { }); describe('Path templates', () => { + describe('cachedContent', () => { + const fakePath = '/rendered/path/cachedContent'; + const expectedParameters = { + id: 'idValue', + }; + const client = new permissionserviceModule.v1beta.PermissionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.cachedContentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cachedContentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cachedContentPath', () => { + const result = client.cachedContentPath('idValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cachedContentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchIdFromCachedContentName', () => { + const result = client.matchIdFromCachedContentName(fakePath); + assert.strictEqual(result, 'idValue'); + assert( + (client.pathTemplates.cachedContentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('chunk', () => { const fakePath = '/rendered/path/chunk'; const expectedParameters = { diff --git a/packages/google-ai-generativelanguage/test/gapic_retriever_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_retriever_service_v1beta.ts index 640f910b656..c73d0278014 100644 --- a/packages/google-ai-generativelanguage/test/gapic_retriever_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_retriever_service_v1beta.ts @@ -3382,6 +3382,44 @@ describe('v1beta.RetrieverServiceClient', () => { }); describe('Path templates', () => { + describe('cachedContent', () => { + const fakePath = '/rendered/path/cachedContent'; + const expectedParameters = { + id: 'idValue', + }; + const client = new retrieverserviceModule.v1beta.RetrieverServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cachedContentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cachedContentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cachedContentPath', () => { + const result = client.cachedContentPath('idValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cachedContentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchIdFromCachedContentName', () => { + const result = client.matchIdFromCachedContentName(fakePath); + assert.strictEqual(result, 'idValue'); + assert( + (client.pathTemplates.cachedContentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('chunk', () => { const fakePath = '/rendered/path/chunk'; const expectedParameters = { diff --git a/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta.ts b/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta.ts index bb6e62756be..6b399fb0f13 100644 --- a/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta.ts +++ b/packages/google-ai-generativelanguage/test/gapic_text_service_v1beta.ts @@ -763,6 +763,44 @@ describe('v1beta.TextServiceClient', () => { }); describe('Path templates', () => { + describe('cachedContent', () => { + const fakePath = '/rendered/path/cachedContent'; + const expectedParameters = { + id: 'idValue', + }; + const client = new textserviceModule.v1beta.TextServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.cachedContentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cachedContentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('cachedContentPath', () => { + const result = client.cachedContentPath('idValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cachedContentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchIdFromCachedContentName', () => { + const result = client.matchIdFromCachedContentName(fakePath); + assert.strictEqual(result, 'idValue'); + assert( + (client.pathTemplates.cachedContentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('chunk', () => { const fakePath = '/rendered/path/chunk'; const expectedParameters = { diff --git a/packages/google-ai-generativelanguage/webpack.config.js b/packages/google-ai-generativelanguage/webpack.config.js index 4b32bfa74e3..6b6d6f8e33f 100644 --- a/packages/google-ai-generativelanguage/webpack.config.js +++ b/packages/google-ai-generativelanguage/webpack.config.js @@ -17,8 +17,8 @@ const path = require('path'); module.exports = { entry: './src/index.ts', output: { - library: 'DiscussService', - filename: './discuss-service.js', + library: 'CacheService', + filename: './cache-service.js', }, node: { child_process: 'empty',