diff --git a/gapic/configurable_snippetgen/__init__.py b/gapic/configurable_snippetgen/__init__.py new file mode 100644 index 0000000000..63f1632862 --- /dev/null +++ b/gapic/configurable_snippetgen/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/gapic/configurable_snippetgen/snippet_config_language.proto b/gapic/configurable_snippetgen/snippet_config_language.proto new file mode 100644 index 0000000000..d1aecb9b98 --- /dev/null +++ b/gapic/configurable_snippetgen/snippet_config_language.proto @@ -0,0 +1,1110 @@ +// Copyright 2022 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.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. + +syntax = "proto3"; + +package google.cloud.tools.snippetgen.configlanguage.v1; + +import "google/protobuf/descriptor.proto"; + +option csharp_namespace = "Google.Cloud.Tools.SnippetGen.ConfigLanguage.V1"; +option php_namespace = "Google\\Cloud\\Tools\\SnippetGen\\ConfigLanguage\\V1"; +option ruby_package = "Google::Cloud::Tools::SnippetGen::ConfigLanguage::V1"; +option java_multiple_files = true; +option java_outer_classname = "SnippetConfigLanguageProto"; +option java_package = "com.google.cloud.tools.snippetgen.configlanguage.v1"; + +// The snippet configuration for a single snippet that will be generated across +// all languages. +message SnippetConfig { + // Metadata for the snippet configuration. Some information contained here + // will be included in the generated snippet own metadata. + SnippetConfigMetadata metadata = 1; + + // The RPC this snippet is for. + Rpc rpc = 2; + + // The generated snippet method signature. + SnippetSignature signature = 3; + + // The actual snippet (code). + Snippet snippet = 4; +} + +// Metadata for the snippet configuration. Some information contained here will +// be included in the generated snippet's own metadata. +message SnippetConfigMetadata { + // Whether this snippet config should be skipped for/ generation. + // This is useful when snippets are developed before features are released. + // Defaults to false. + bool skipped = 1; + + // List of languages to skip snippet generation for. + // Config producers should specify here languages for which some of the + // capabilities required by the snippet are not supported. For instance, if a + // specific client option is required by the snippet, and that option is not + // supported by .NET client libraries, then C_SHARP should be specified here. + repeated GeneratorOutputLanguage skipped_languages = 2; + + // The config id. This will be used to generate the region tag of the snippet. + // Required. + // The region tag format will be: + // [{START|END} + // ${apishortname}_${apiVersion}_config_${ServiceName}_${RpcName}_${config_id}_{sync|async}] + // - config_id must be unique for a given Service/RPC pair. + // - config_id must not contain the API, Service or RPC identifiers as that + // will be automatically included in the region tag. + // - config_id may only contain letters and numbers + // - config_id should be PascalCased + // - Preferable, config_id should not exceed 50 characters, although this is + // not a hard requirement. + // - config_id may be somewhat descriptive of the snippet or just a random + // identifier. If it's descriptive, do not make it overly verbose, there are + // the human readable snippet_name and snippet_description fields for properly + // describing the snippet. For instance, prefer DefaultDatasetCreation to + // DatasetCreationUsingDefaultValuesExceptForDatasetNameWhichIsRequired. + string config_id = 3; + + // The human readable name of the snippet. + // To be included in metadata and in the sample itself in the top-level + // description. + string snippet_name = 4; + + // The description of the snippet. + // To be included in metadata and in the sample itself in the top-level + // description. + string snippet_description = 5; +} + +// A programming language in which snippets are generated. +// Note that this is different from +// google.cloud.tools.snippetgen.snippetindex.v1.Language, i.e. language +// specified in snippet metadata, as metadata can be written for both generated +// and handwritten snippets. In turn, we'll always know which generators we are +// writing snippet configs for and which are the output languages of those +// generators. +enum GeneratorOutputLanguage { + // The language has not been specified. Consumers should not see this value. + GENERATOR_OUTPUT_LANGUAGE_UNSPECIFIED = 0; + C_PLUS_PLUS = 1; + C_SHARP = 2; + GO = 3; + JAVA = 4; + JAVASCRIPT = 5; + PHP = 6; + PYTHON = 7; + RUBY = 8; +} + +// An RPC for which a Snippet may be defined. +message Rpc { + // This is identical to the protobuf package ending with a version number, + // after removing said version number. For instance, where the api ID is + // "google.cloud.translate.v3" the API name is "google.cloud.translate". + string proto_package = 1; + + // The list of API versions for which one snippet is defined. + // The same RPC may exist in different versions (v1, v1beta, v2) of the API + // and may be covered by the same snippet config. + repeated string api_version = 2; + + // The protobuf service name relative to the api name + version where the RPC + // is defined. Example: "TransalationService". + string service_name = 3; + + // The RPC name relative to the service name. + string rpc_name = 4; +} + +message SnippetSignature { + // The name for the snippet method specified in snake_case. Required. + string snippet_method_name = 1; + + // The return type for the snippet method. Unset for methods that do not + // return a value or if the sample is to be generated for non statically-typed + // languages only. + Type return_type = 2; + + // Synchronous preference indicator for the generated snippet. + SyncPreference sync_preference = 3; + + // The list of parameters that the snippet will receive. May be empty if the + // snippet method does not receive parameters. If any, parameters should + // appear in generated code in the same order as they appear in this field. + // Note also that if parameters have assignments, some languages + // will represent these as default parameter values which are + // usually scalars. + repeated Statement.Declaration parameters = 4; + + // Synchronous preference indicator for the generated snippet. + // Note that some languages only support one-off sync or async methods so this + // is just a preference indicator. + enum SyncPreference { + // Generate an async, sync or both snippets as per language + // (style, guidelines, community) preference. + LANGUAGE_PREFERRED = 0; + + // Languages supporting async methods should generate an async snippet. + // Languages that do not support async methods will generate a sync snippet + // instead. + PREFER_ASYNC = 1; + + // Languages supporting sync methods should generate a sync snippet. + // Languages that do not support sync methods will generate an async snippet + // instead. + PREFER_SYNC = 2; + + // Languages that support both async and sync methods should generate both a + // sync and an async snippets. Note that different samples should be in + // differnt files. + // Languages that support only one of async and sync methods should + // generate the supported snippet. + BOTH = 3; + } +} + +// The actual snippet (code), including client and request initialization, +// client call and response handling. +message Snippet { + // Service client initialization. Optional. If unset language-specific + // defaults will be applied. + ClientInitialization service_client_initialization = 1; + + // Call configuration including request initialization and response handling. + // Required. + oneof call { + // A standard RPC operation. + Standard standard = 2; + + // A paginated RPC operation. + Paginated paginated = 3; + + // A long-running RPC operation. + Lro lro = 4; + + // A client streaming RPC operation. + ClientStreaming client_streaming = 5; + + // A server streaming RPC operation. + ServerStreaming server_streaming = 6; + + // A bidirectional streaming RPC operation. + BidiStreaming bidi_streaming = 7; + } + // Statements to be executed before the snippet ends. For instance, some + // Statement.StandardOutput statements and the Statement.Return statement. + // May be empty. If any, statements should appear on generated code in the + // same order as they appear on this field. + repeated Statement final_statements = 8; + + // Options to initialize the client with. + message ClientInitialization { + // Statements to be executed before the service client is initialized. For + // instance, some Statement.Declaration statements of variables to be used + // in service client initialization. May be empty. If any, statements will + // be executed in the same order as they appear on + // pre_request_initialization. + repeated Statement pre_client_initialization = 1; + + // Custom endpoint to use in client initialization. Optional. + ServiceEndpoint custom_service_endpoint = 2; + + // Different languages have different requirements for how a service + // endpoint should be specified, so in sample configuration the endpoint + // needs to be specified in parts that each language generator can then use + // to compose the string literal to include in the sample according to their + // own requirements. None of this manipulation should be included in the + // sample itself, where only a string literal is expected as the value for + // the custom endpoint. + message ServiceEndpoint { + // The schema for the service endpoint. + ServiceEndpointSchema schema = 1; + + // The unregionalized host for the service endpoint. + // For instance "pubsub.googleapis.com". Required. + string host = 2; + + // The region if this is a regional endpoint. + // For instance "us-east1". Optional. + // If present the regional host should be constructed as follows: + // {region}-{host}. + string region = 3; + + // The port for the service endpoint. Optional. + // Languages that require a port to be specified should use the same + // default value as they do in library generation. + int32 port = 4; + + // Schemas for the service endpoint. + enum ServiceEndpointSchema { + // Each language to use their own default. + // Languages that do not require the schema to be specified, + // may omit it when building the custom endpoint. + // Languages that require the schema to be specified should use the + // same default value as they do in library generation. + LANGUAGE_DEFAULT = 0; + + // Use HTTPS for service endpoint schema. + HTTPS = 1; + + // Use HTTP for service endpoint schema. + HTTP = 2; + } + } + } + + // A standard RPC operation. + message Standard { + // Describes how to initialize the request object. Required. + SimpleRequestInitialization request_initialization = 1; + + // Client call configuration. Optional. + ClientCall call = 2; + + // Describes how to handle simple responses. Optional. + SimpleResponseHandling response_handling = 3; + } + + // A paginated RPC operation. + message Paginated { + // Describes how to initialize the request object. This is the request + // object used for the initial paginated RPC call. Depending on how the + // response should be handled subsequent requests will be initialized either + // implicitly by the library or explicitly by the snippet. + SimpleRequestInitialization request_initialization = 1; + + // Client call configuration. Optional. + // This configures the client call, which in turn may result in several RPC + // calls. How this configuration is applied to RPC calls may be language + // specific. + ClientCall paginated_call = 2; + + // Describes how to handle paginated responses. + PaginatedResponseHandling paginated_handling = 3; + } + + // A long-running RPC operation. + message Lro { + // Describes how to initialize the request object. Required. + // This describes the request to the LRO operation itself and not to polling + // operations. + SimpleRequestInitialization request_initialization = 1; + + // Client call configuration. Optional. + // This configures the call to the LRO operation itself and not to polling + // operations. + ClientCall call = 2; + + // Describes how to handle the LRO response. Required. + LroResponseHandling lro_handling = 3; + } + + // A client streaming RPC operation. + message ClientStreaming { + // Client call configuration. Optional. + // This configures the call that initializes the stream. + ClientCall initialization_call = 1; + + // The name of the variable to capture the client stream in, i.e. the object + // in which streaming requests are written. Required. + string client_stream_name = 2; + + // Describes how to initialize the streaming request objects. Required. + StreamingRequestInitialization request_initialization = 3; + + // Describes how to handle the response. Optional. + // Note that the response will be available after all the streaming requests + // have been written, each language should generate code accordingly. + SimpleResponseHandling response_handling = 4; + } + + // A server streaming RPC operation. + message ServerStreaming { + // Describes how to initialize the request object. Required. + SimpleRequestInitialization request_initialization = 1; + + // Client call configuration. Optional. + ClientCall initialization_call = 2; + + // The name of the variable to capture the server stream in, i.e. the object + // from which streaming responses will be read. Optional if the stream is + // not to be read. + string server_stream_name = 3; + + // Describes how to handle the streaming responses. Optional if the stream + // is not to be read. + StreamingResponseHandling response_handling = 4; + } + + // A bidirectional streaming RPC operation. + message BidiStreaming { + // Client call configuration. Optional. + // This configures the call that initializes de stream. + ClientCall initialization_call = 1; + + // The name of the variable to capture the client stream in, i.e. the object + // in which streaming requests are written. Required. + string client_stream_name = 2; + + // Describes how to initialize the streaming request objects. Required. + StreamingRequestInitialization request_initialization = 3; + + // The name of the variable to capture the server stream in, i.e. the object + // from which streaming responses will be read. Optional if the stream is + // not to be read. + string server_stream_name = 4; + + // Describes how to handle the streaming responses. Optional if the stream + // is not to be read. + StreamingResponseHandling response_handling = 5; + } + + // An actual client service call. + // Note: Just pre_call statements for now, but this message is included so + // that adding per call options later on is not a breaking change. + message ClientCall { + // Statements to be executed before the initial call to the service client + // method is made. Whether that results in an RPC call or not is operation + // type and language dependent. May be empty. + // If any, statements should appear in generated code in the same order as + // they appear on this field. + repeated Statement pre_call = 2; + + // TODO: Add per call options, including retries, etc. + } + + // Describes how to initialize a simple request object. + message SimpleRequestInitialization { + // Statements to be executed before the request object is initialized. For + // instance, some Statement.Declaration statements of variables to be used + // in request initialization. May be empty. If any, statements will be + // executed in the same order as they appear on pre_request_initialization. + repeated Statement pre_request_initialization = 1; + + // The request value. Required. + // Should resolve to a type that is assignable to the request type of the + // RPC. + Expression request_value = 2; + + // The name for the variable that will hold the request object. + // For example "request". Required. + string request_name = 3; + } + + // Describes how to make requests to client streaming RPCs. + // An iteration is defined which makes some per-iteration + // Expression.NameValue availables that may be used to define + // streaming_request. + message StreamingRequestInitialization { + // Describes how to initialize the first streaming request. Optional for + // operations that do not require a specific first request. + SimpleRequestInitialization first_streaming_request = 1; + + // The iteration to use for defining the streaming requests. Required. + Statement.Iteration iteration = 3; + + // The streaming request that may be defined with iteration-specific + // variables, and will result in a sequence of requests. Required. + // Initialization of streaming_request should be placed, in generated code, + // on the inner-most iteration defined by the iteration field as iterations + // may be nested. + SimpleRequestInitialization streaming_request = 4; + } + + // Describes how to handle a simple response object. + message SimpleResponseHandling { + // The name of the variable to capture the response in. May be unset if + // the RPC does not return anything or the response is not to be captured. + string response_name = 1; + } + + // Describes how to handle paginated responses. + message PaginatedResponseHandling { + // The name of the variable to capture the initial client call response in. + // Required. Note that this will capture the object representing the lazy + // item sequence. + string response_name = 1; + + // How to iterate over the items. Optional. If unset, no iterations will be + // performed over the paginated response. + oneof pagination_kind { + // Iterate item by item, lazily and automatically fetching pages as + // needed. + ByItem by_item = 2; + + // Iterate page by page, lazily and automatically fetching pages as + // needed. + ByPage by_page = 3; + + // Iterate page by page, explicitly using the next page token. + // This pagination mode will modify the original request by subsequently + // setting the next page token obtained from the previous response. + NextPageToken next_page_token = 4; + } + + // Iterate item by item, lazily and automatically fetching pages as needed. + message ByItem { + // The name of the variable to capture the current item in. Required. + string item_name = 1; + + // Statements to execute for each item. Optional. + repeated Statement per_item_statements = 2; + } + + // Iterate page by page, lazily and automatically fetching pages as needed. + message ByPage { + // The name of the variable to capture the current page in. Required. + string page_name = 1; + + // Statements to execute for each page. Optional. + repeated Statement per_page_statements = 2; + + // By item iteration configuration within the current page. Optional. + ByItem by_item = 3; + } + + // Iterate page by page, explicitly using the next page token. + // This pagination mode will modify the original request by subsequently + // setting the next page token obtained from the previous response. + message NextPageToken { + // The name of the variable to capture the next page token in. Required. + string next_page_token_name = 1; + + // The explicit and guaranteed page size for fetched pages. Required. + // TODO: Double check that all languages have this modality. + // Otherwise, they may fallback to by page iteration. + Expression explicit_page_size = 2; + + // Configures how to iterate over the explicitly fetched page. + ByPage by_page = 3; + } + } + + // Describes how to handle LRO responses. + message LroResponseHandling { + // The name of the variable to capture the LRO response in. Required. + // This will capture the response to the LRO operaion call and not to + // polling operations. + string response_name = 1; + + // How to perform polling. Required. + PollingType polling_type = 2; + + // The name of the variable to capture the polling response in. Optional if + // the polling result should not be captured. Should be unset if + // PollingType.NONE is specified. + string polling_response_name = 3; + + // Configures the polling call. Optional. Should be unset if + // PollingType.NONE is specified. + ClientCall polling_call = 4; + + enum PollingType { + // Poll until completion. Default value. + UNTIL_COMPLETION = 0; + + // Poll just once. + ONCE = 1; + + // Do not poll. + NONE = 2; + } + } + + // Describes how to handle streaming responses. + message StreamingResponseHandling { + // The name of the variable to capture the current response in the stream. + // Required. + string current_response_name = 1; + + // Statements to execute for each stream response. Optional. + repeated Statement per_stream_response_statements = 2; + } +} + +// A stament that will translate into equivalent language-specific statements. +message Statement { + oneof statement_type { + // A declaration which may be used for parameters or variables. Note that + // the only form of assignment supported is on declaration. + // Note that a declaration has scope depending on whether it's included as + // a top level statement in any of the snippet sections or is a nested + // statement. + Declaration declaration = 1; + + // A statement to write information to sdtout. + StandardOutput standard_output = 2; + + // A return statement. + Return return = 3; + + // A conditional statement. One of two given sets of statements will be + // executed depending on the result of evaluating a given condition. + Conditional conditional = 4; + + // An iteration statement. A given Statement set will be executed + // repeatedly according to the iteration definition. + // Each iteration type will make a per-step Expression.NameValue set + // available that may be used withing the given Statement set. + Iteration iteration = 5; + } + + // A declaration which may be used for parameters or variables. + // Note that the only form of assignment supported is on declaration. + message Declaration { + // The type of this declaration. Required unless the snippet is to be + // generated in non-statically typed languages only. + Type type = 1; + + // The name of the variable or parameter. Required. + string name = 2; + + // The value to assign to the variable or parameter. + // Optional for parameters. + // Required for variables as assignment outside of a declaration is not + // supported. + // Should resolve to a type that is assignable to this Declaration type. + Expression value = 3; + + // An optional description that will be included alongside the declaration + // likely as a code comment. + string description = 4; + } + + // A statement to write information to sdtout. + message StandardOutput { + // The value to write to sdtout. + // Should evaluate to a string value or resolve to a type that all languages + // are able to convert to string without specific code, for instance numeric + // values, and possibly protobuf messages as they may be converted to their + // JSON representation. + Expression value = 2; + } + + // A return statement. + message Return { + // The value to return. Should resolve to a type that is assignable to + // SnippetSignature.return_type. + Expression result = 1; + } + + // A conditional statement. One of two given sets of statements will be + // executed depending on the result of evaluating a given condition. + message Conditional { + // The condition to evaluate. Should evaluate to a bolean value. + Expression condition = 1; + + // The set of statements to execute if condition evaluates to true. + // The statements should be executed in the order that they appear. + repeated Statement on_true = 2; + + // The set of statements to execute if condition evaluates to false. + // The statements should be executed in the order that they appear. + repeated Statement on_false = 3; + } + + // An iteration statement. A given Statement set will be executed + // repeatedly according to the iteration definition. + // Each iteration type will make a per-step Expression.NameValue set + // available that may be used withing the given Statement set. + message Iteration { + oneof iteration_type { + // A numeric sequence iteration. + NumericSequenceIteration numeric_sequence_iteration = 1; + + // An iteration over repeated elements, i.e. an iteration over a list. + RepeatedIteration repeated_iteration = 2; + + // A map iteration. + MapIteration map_iteration = 3; + + // A bytes sequence iteration. + BytesIteration bytes_iteration = 4; + } + + // The set of statements to execute on each step of the iteration. + // The statements should be executed in the order that they appear. + // May be empty as iterations will also be used for streaming request + // initialization or streaming response handling. + repeated Statement statements = 5; + + // Represents a numeric sequence iteration. + // A numeric sequence is defined over which to iterate making the current + // element of the sequence available in a variable. + // It's ultimately the responsability of the user to define a finite + // sequence, although tooling may be provided to help. + message NumericSequenceIteration { + // Where to start the sequence at, ie. the first element of the iteration. + // Required. + // The Statement.Declaration.type should be a numeric type. + // The Statement.Declaration.value is required. + // The Statement.Declaration.name will be the name used to make the + // current element of the iteration available. + Statement.Declaration start_at = 1; + + // The step to advance the sequence with. Required. + oneof step { + // An increment, which may be a positive or negative value. + // Should resolve to a numeric type. + Expression increment = 3; + + // A multiplier, which may be less than or greater than 1. + // Should resolve to a numeric type. + Expression multiplier = 4; + } + + // When to end the sequence. Required. + oneof end { + // When the current value is less than or equal to this value. + // Should resolve to a numeric type. + Expression less_than_or_equal = 7; + + // When the current value is less than this value. + // Should resolve to a numeric type. + Expression less_than = 8; + + // When the current value is greater than or equal to this value. + // Should resolve to a numeric type. + Expression greater_than_or_equal = 9; + + // When the current value is greater than this value. + // Should resolve to a numeric type. + Expression greater_than = 10; + + // After a set number of steps. Must be non-negative. + // Should resolve to an integer type. + Expression total_steps = 11; + } + } + + // Represents an iteration over repeated elements. + // A repeated value is provided over which the iteration will occur making + // the current element of the sequence available in a variable. + message RepeatedIteration { + // The repeated elements to iterate over. Required. + // The Statement.Declaration.type should be Type.RepeatedType. + // The Statement.Declaration.value is required. + // TODO: Consider this to be a oneof Declaration or Expression.NameValue. + Statement.Declaration repeated_elements = 1; + + // The name of the variable that will hold the value of the current + // element on each iteration. For example "item". Required. The type of + // this variable will be the same as that of the elements in + // repeated_elements. + string current_name = 2; + + // TODO: Do we expose the element index as well? Optionally? + } + + // Represents an iteration over a map. + // A map value is provided over which the iteration will occur making + // the current key and element of the map availables in variables. + message MapIteration { + // The map to iterate over. Required. + // The Statement.Declaration.type should be Type.MapType. + // The Statement.Declaration.value is required. + // TODO: Consider this to be a oneof Declaration or Expression.NameValue. + Statement.Declaration map = 1; + + // The name of the variable that will hold the value of the current key + // on each iteration. For example "key". Required. + // The type of this variable will be the same as that of the keys in map. + string current_key_name = 2; + + // The name of the variable that will hold the value associated to the + // current key on each iteration. For example "value". Required. + // The type of this variable will be the same as that of the values in + // map. + string current_value_name = 3; + } + + // Represents an iteration over a byte sequence. + // A byte sequence is provided over which the iteration will occur making + // the current chunk of bytes available in a variable. + message BytesIteration { + // The byte sequence to iterate over. Required. + // The Statement.Declaration.type should be Type.BytesType. + // The Statement.Declaration.value is required. + Statement.Declaration byte_sequence = 1; + + // How to split the byte sequence in chunks to iterate over. + oneof chunk { + // The size of the chuncks to split the byte sequence in. The last chunk + // will be at most chunk_size. Must be positive. + // Should resolve to an integer type. + Expression chunk_size = 2; + + // The total amount of chunks to split the byte sequence into. Note that + // this is only possible when the byte sequence has a known length so it + // might not be possible with certain streams, for instance, with + // network streams. Must be positive. + // Should resolve to an integer type. + Expression total_chunks = 3; + } + // The type in which the chunk will be made available. + Type.BytesType chunk_type = 4; + + // The name of the variable that will hold the value of the current chunk + // on each iteration. For example "chunk". Required. + // Will be of type chunk_type. + string current_name = 5; + } + } +} + +// Represents type of values. To be used, for instance, for +// Statement.Declaration or for specifying the return type of the snippet. +message Type { + oneof type_kind { + // Protobuf scalar types. + ScalarType scalar_type = 1; + + // Protobuf enum types. + EnumType enum_type = 2; + + // The bytes type + BytesType bytes_type = 3; + + // Protobuf message types. + MessageType message_type = 4; + + // The repeated type. + RepeatedType repeated_type = 5; + + // The map type. + MapType map_type = 6; + } + + // Represents protobuf scalar types that should be translated to the usual + // language-specific types. + // https://developers.google.com/protocol-buffers/docs/proto3#scalar + // This could have been FieldDescriptorProto.Type except that proto2 enums + // cannot be used in proto3. Also, a few of the types in + // FieldDescriptorsProto.Type are individually supported in SnippetGen Config. + // Values allowed for this type are: + // - Expression.default_value, + // - Expression.name_value as long as the identifier resolves to a type that + // is assignable to this one. + // - Expression.number_value for the numeric FieldDescriptorProto.Type(s). + // - Expression.boolean_value for FieldDescriptorProto.Type.TYPE_BOOL. + // - Expression.string_value for FieldDescriptorProto.Type.TYPE_STRING. + // - Any other value that resolves to a type that is assignable to this one. + enum ScalarType { + // The scalar type has not been specified. Consumers should not see this + // value. + SCALAR_TYPE_UNDEFINED = 0; + TYPE_DOUBLE = 1; + TYPE_FLOAT = 2; + TYPE_INT64 = 3; + TYPE_UINT64 = 4; + TYPE_INT32 = 5; + TYPE_FIXED64 = 6; + TYPE_FIXED32 = 7; + TYPE_BOOL = 8; + TYPE_STRING = 9; + TYPE_UINT32 = 13; + TYPE_SFIXED32 = 15; + TYPE_SFIXED64 = 16; + TYPE_SINT32 = 17; + TYPE_SINT64 = 18; + } + + // Represents protobuf enum types. These should be known by the + // microgenerators on generation time, so they'll probably be enums defined + // within the API being generated or one of its mixins. + message EnumType { + // The protobuf full enum name, including the protobuf package. + string enum_full_name = 1; + } + + // Represents a bytes type. + message BytesType { + // The language-specific type that this bytes type should be generated as. + LanguageEquivalent language_equivalent = 1; + + // Possible language-specific equivalents to a bytes type. + enum LanguageEquivalent { + // The same type used for representing protobuf bytes fields. + PROTOBUF_BYTES = 0; + + // Language-specific string type, whose value will be understood as a + // base64 string representation of the bytes. + BASE64 = 1; + + // Language-specific byte array type. + BYTE_ARRAY = 2; + + // Language-specific stream type. + STREAM = 3; + } + } + + // Represents protobuf message types. These should be known by the + // microgenerators at generation time, so they'll usually be well known types, + // messaged defined within the API being generated or one of its mixins. + message MessageType { + // The protobuf full message name, including the protobuf package. + string message_full_name = 1; + } + + // Represents a repeated type. + message RepeatedType { + // The type of the elements. + Type element_type = 1; + + // The language-specific type that this repeated type should be generated + // as. + LanguageEquivalent language_equivalent = 2; + + // Possible language-specific equivalents to a repeated type. + enum LanguageEquivalent { + // The same type used for representing protobuf repeated fields. + PROTOBUF_REPEATED = 0; + + // Language-specific array type. + ARRAY = 1; + + // Language-specific list type. + LIST = 2; + } + } + + // Represents a map type. + message MapType { + // The type of the keys. + Type key_type = 1; + + // The type of the values. + Type value_type = 2; + + // The language-specific type that this map type should be generated as. + LanguageEquivalent language_equivalent = 3; + + // Possible language-specific equivalents to a map type. + enum LanguageEquivalent { + // The same type used for representing protobuf map fields. + PROTOBUF_MAP = 0; + + // Language-specific dictionary or map type. + DICTIONARY = 1; + } + } +} + +// An expression to be used, for instance, for parameter, variable and request +// initialization. +// On type inference: +// - When used for parameter or variable initialization, that is, when used in a +// Statement.Declaration, we have Statement.Declaration.Type. +// - When used for request initialization, we know the request type. +// - When used to initialize other elements, like client options, etc. we will +// know which types may be infer on a case by case basis as specified by each +// of these elements documentation. +message Expression { + // The literal or calculated value. + oneof value { + // The null value. Might not be accepted by all types. + NullValue null_value = 1; + + // The default value. + // Note that when a value is used, type is always known/inferred. Supported + // types are currently protobuf scalar types and protobuf message types so + // all types should have a default value. + DefaultValue default_value = 2; + + // A variable or parameter name, and possibly a path within. + NameValue name_value = 3; + + // A number literal. + double number_value = 4; + + // A Boolean literal. + bool boolean_value = 5; + + // A string literal. + string string_value = 6; + + // An enum value. The text is to be the enum value name as defined in + // protobuf. For instance, for a protobuf enum + // `enum SampleEnum { VALUE_0 = 0; VALUE_1 = 1; }` + // the accepted values here would be VALUE_0 and VALUE_1. + string enum_value = 7; + + // A bytes value. This represents initialization of objects from which + // arbitrary byte sequences may be obtained. + BytesValue bytes_value = 8; + + // A complex value. This represents initialization of complex objects, most + // likely of protobuf messages. + ComplexValue complex_value = 9; + + // A list value. This represents initialization of collections, list, arrays + // and similar values. + RepeatedValue list_value = 10; + + // A map value. This represents initialization of maps, dictionaries and + // similar values. + MapValue map_value = 11; + + // A conditional value. This expression has one of two given values + // depending on the result of evaluating a given condition. + ConditionalOperator conditional_value = 12; + + // TODO: We will need a resource name operator, languages that have resource + // name support can translate this operator to their language-specific + // resource name helpers and languages that don't can simply build the + // resource name string. + } + + // An optional description that will be included in the snippet alongside the + // value, likely as a code comment. + string description = 13; + + // The null value. Might not be accepted by all types. + enum NullValue { + // Null value. + NULL_VALUE = 0; + } + + // The default value. + // Note that when a value is used, the type is always known/inferred. + // Supported types are currently protobuf scalar types and protobuf message + // types so all types should have a default value. + // For protobuf message types, the default value should be the empty message. + enum DefaultValue { + // Default value. + DEFAULT_VALUE = 0; + } + + // A variable or parameter name. + message NameValue { + // The name of the variable or parameter name. Required. + string name = 1; + + // A path within name that refers to a nested value. Optional. + // Note that this path must be valid across all languages, so, the following + // rules apply. + // - A path in a NameValue is only allowed if name refers to a value of + // google.cloud.tools.snippetgen.configlanguage.v1.Type.MessageType, i.e. + // a protobuf message. + // - The path segments should be named as they appear on the proto + // definition and not as they are on any specific language. + // For instance, if the following message is defined: + // ``` + // message SampleMessage { + // int one_field = 0; + // SampleMessage nested_field = 1; + // } + // ``` + // and a Declaration of + // - Declaration.type => SampleMessage and + // - Declaration.name => sample_value + // then posible NameValues that refer to the variable declared are: + // - NameValue.name => sample_value and NameValue.path => unset to reference + // the value of the sample_value variable, i.e. using the variable + // sample_value + // - NameValue.name => sample_value and NameValue.path => one_field to + // reference the value of the one_field value of the message instance + // stored in the sample_value variable, i.e. using the variable + // sample_value.one_field. + // - NameValue.sample_value and NameValue.path => nested_field, one_field to + // reference the one_field value of the nested_field value of the message + // instance stored in the sample_value variable, i.e. using the variable + // sample_value.nested_field.one_field. + repeated string path = 2; + } + + // A bytes value. This represents initialization of objects from which + // arbitrary byte sequences may be ontained. + message BytesValue { + oneof value { + // A Base64 encoded string. + // This expression should resolve to a string value. + Expression base64_string = 1; + + // A file stream. + FileStream file_stream = 2; + } + + // A language-specific file stream. + message FileStream { + // The path of the file to build the stream from. + // This expression should evaluate to a string value. + Expression file_path = 1; + } + } + + // A complex value. This represents initialization of complex objects, most + // likely of protobuf messages. + message ComplexValue { + // This is a simple map from message property name to Expression. + // - All keys in the map should correspond to top level properties of the + // protobuf message. + // - Nested properties may be initialized thanks to the recursive nature of + // ComplexValue. + // - Each Expression in the map should resolve to the type of the property + // whose name is the associated key. + map properties = 1; + } + + // A list value. This represens initialization of collections, list, arrays + // and similar values. + message RepeatedValue { + // The values that should be used to initialize a language-specific + // collection, list, array or similar. + // - The values should be used in the same order as they appear in values, + // regardless of whether the target collection type represents an ordered + // collection or not. + // - Each Expression should resolve to a type that is assignable to the type + // of the elements in the target collection. + repeated Expression values = 1; + } + + // A map value. This represents initialization of maps, dictionaries and + // similar values. + // Note that we cannot use a protobuf map for the definition of MapValue + // because protobuf map do not accept message types as the key type. + message MapValue { + // The keys to use for initializing a language-specific map, dictionary or + // similar. + // - Each key Expression should resolve to a type that is assignable to + // the key type of the target map. + repeated Expression keys = 1; + + // The values to use for initializing a language-specific map, dictionary or + // similar. + // - Each value Expression should resolve to a type that is assignable to + // the value type of the target map. + // - Each value should be present in the same order as the corresponding key + // is in keys. + repeated Expression values = 2; + } + + // A conditional value. This expression has one of two given values + // depending on the result of evaluating a given condition. + message ConditionalOperator { + // The condition to evaluate. Should resolve to a Boolean value. + Expression condition = 1; + + // The value of this expression if condition evaluates to true. on_true + // should resolve to a type that is assignable to the target type of this + // expression. + Expression on_true = 2; + + // The value of this expression if condition evaluates to false. on_false + // should resolve to a type that is assignable to the target type of this + // expression. + Expression on_false = 3; + } +} diff --git a/gapic/configurable_snippetgen/snippet_config_language_pb2.py b/gapic/configurable_snippetgen/snippet_config_language_pb2.py new file mode 100644 index 0000000000..938060d5ea --- /dev/null +++ b/gapic/configurable_snippetgen/snippet_config_language_pb2.py @@ -0,0 +1,158 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: snippet_config_language.proto +# type: ignore +"""Generated protocol buffer code.""" +from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor__pb2 +from google.protobuf.internal import builder as _builder +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( + b'\n\x1dsnippet_config_language.proto\x12/google.cloud.tools.snippetgen.configlanguage.v1\x1a google/protobuf/descriptor.proto\"\xcd\x02\n\rSnippetConfig\x12X\n\x08metadata\x18\x01 \x01(\x0b\x32\x46.google.cloud.tools.snippetgen.configlanguage.v1.SnippetConfigMetadata\x12\x41\n\x03rpc\x18\x02 \x01(\x0b\x32\x34.google.cloud.tools.snippetgen.configlanguage.v1.Rpc\x12T\n\tsignature\x18\x03 \x01(\x0b\x32\x41.google.cloud.tools.snippetgen.configlanguage.v1.SnippetSignature\x12I\n\x07snippet\x18\x04 \x01(\x0b\x32\x38.google.cloud.tools.snippetgen.configlanguage.v1.Snippet\"\xd3\x01\n\x15SnippetConfigMetadata\x12\x0f\n\x07skipped\x18\x01 \x01(\x08\x12\x63\n\x11skipped_languages\x18\x02 \x03(\x0e\x32H.google.cloud.tools.snippetgen.configlanguage.v1.GeneratorOutputLanguage\x12\x11\n\tconfig_id\x18\x03 \x01(\t\x12\x14\n\x0csnippet_name\x18\x04 \x01(\t\x12\x1b\n\x13snippet_description\x18\x05 \x01(\t\"Y\n\x03Rpc\x12\x15\n\rproto_package\x18\x01 \x01(\t\x12\x13\n\x0b\x61pi_version\x18\x02 \x03(\t\x12\x14\n\x0cservice_name\x18\x03 \x01(\t\x12\x10\n\x08rpc_name\x18\x04 \x01(\t\"\x99\x03\n\x10SnippetSignature\x12\x1b\n\x13snippet_method_name\x18\x01 \x01(\t\x12J\n\x0breturn_type\x18\x02 \x01(\x0b\x32\x35.google.cloud.tools.snippetgen.configlanguage.v1.Type\x12i\n\x0fsync_preference\x18\x03 \x01(\x0e\x32P.google.cloud.tools.snippetgen.configlanguage.v1.SnippetSignature.SyncPreference\x12Z\n\nparameters\x18\x04 \x03(\x0b\x32\x46.google.cloud.tools.snippetgen.configlanguage.v1.Statement.Declaration\"U\n\x0eSyncPreference\x12\x16\n\x12LANGUAGE_PREFERRED\x10\x00\x12\x10\n\x0cPREFER_ASYNC\x10\x01\x12\x0f\n\x0bPREFER_SYNC\x10\x02\x12\x08\n\x04\x42OTH\x10\x03\"\x91,\n\x07Snippet\x12t\n\x1dservice_client_initialization\x18\x01 \x01(\x0b\x32M.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientInitialization\x12U\n\x08standard\x18\x02 \x01(\x0b\x32\x41.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.StandardH\x00\x12W\n\tpaginated\x18\x03 \x01(\x0b\x32\x42.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.PaginatedH\x00\x12K\n\x03lro\x18\x04 \x01(\x0b\x32<.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.LroH\x00\x12\x64\n\x10\x63lient_streaming\x18\x05 \x01(\x0b\x32H.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientStreamingH\x00\x12\x64\n\x10server_streaming\x18\x06 \x01(\x0b\x32H.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ServerStreamingH\x00\x12`\n\x0e\x62idi_streaming\x18\x07 \x01(\x0b\x32\x46.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.BidiStreamingH\x00\x12T\n\x10\x66inal_statements\x18\x08 \x03(\x0b\x32:.google.cloud.tools.snippetgen.configlanguage.v1.Statement\x1a\xff\x03\n\x14\x43lientInitialization\x12]\n\x19pre_client_initialization\x18\x01 \x03(\x0b\x32:.google.cloud.tools.snippetgen.configlanguage.v1.Statement\x12~\n\x17\x63ustom_service_endpoint\x18\x02 \x01(\x0b\x32].google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientInitialization.ServiceEndpoint\x1a\x87\x02\n\x0fServiceEndpoint\x12\x83\x01\n\x06schema\x18\x01 \x01(\x0e\x32s.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientInitialization.ServiceEndpoint.ServiceEndpointSchema\x12\x0c\n\x04host\x18\x02 \x01(\t\x12\x0e\n\x06region\x18\x03 \x01(\t\x12\x0c\n\x04port\x18\x04 \x01(\x05\"B\n\x15ServiceEndpointSchema\x12\x14\n\x10LANGUAGE_DEFAULT\x10\x00\x12\t\n\x05HTTPS\x10\x01\x12\x08\n\x04HTTP\x10\x02\x1a\xbf\x02\n\x08Standard\x12t\n\x16request_initialization\x18\x01 \x01(\x0b\x32T.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.SimpleRequestInitialization\x12Q\n\x04\x63\x61ll\x18\x02 \x01(\x0b\x32\x43.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientCall\x12j\n\x11response_handling\x18\x03 \x01(\x0b\x32O.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.SimpleResponseHandling\x1a\xce\x02\n\tPaginated\x12t\n\x16request_initialization\x18\x01 \x01(\x0b\x32T.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.SimpleRequestInitialization\x12[\n\x0epaginated_call\x18\x02 \x01(\x0b\x32\x43.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientCall\x12n\n\x12paginated_handling\x18\x03 \x01(\x0b\x32R.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.PaginatedResponseHandling\x1a\xb2\x02\n\x03Lro\x12t\n\x16request_initialization\x18\x01 \x01(\x0b\x32T.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.SimpleRequestInitialization\x12Q\n\x04\x63\x61ll\x18\x02 \x01(\x0b\x32\x43.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientCall\x12\x62\n\x0clro_handling\x18\x03 \x01(\x0b\x32L.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.LroResponseHandling\x1a\xf4\x02\n\x0f\x43lientStreaming\x12`\n\x13initialization_call\x18\x01 \x01(\x0b\x32\x43.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientCall\x12\x1a\n\x12\x63lient_stream_name\x18\x02 \x01(\t\x12w\n\x16request_initialization\x18\x03 \x01(\x0b\x32W.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.StreamingRequestInitialization\x12j\n\x11response_handling\x18\x04 \x01(\x0b\x32O.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.SimpleResponseHandling\x1a\xf4\x02\n\x0fServerStreaming\x12t\n\x16request_initialization\x18\x01 \x01(\x0b\x32T.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.SimpleRequestInitialization\x12`\n\x13initialization_call\x18\x02 \x01(\x0b\x32\x43.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientCall\x12\x1a\n\x12server_stream_name\x18\x03 \x01(\t\x12m\n\x11response_handling\x18\x04 \x01(\x0b\x32R.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.StreamingResponseHandling\x1a\x91\x03\n\rBidiStreaming\x12`\n\x13initialization_call\x18\x01 \x01(\x0b\x32\x43.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientCall\x12\x1a\n\x12\x63lient_stream_name\x18\x02 \x01(\t\x12w\n\x16request_initialization\x18\x03 \x01(\x0b\x32W.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.StreamingRequestInitialization\x12\x1a\n\x12server_stream_name\x18\x04 \x01(\t\x12m\n\x11response_handling\x18\x05 \x01(\x0b\x32R.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.StreamingResponseHandling\x1aZ\n\nClientCall\x12L\n\x08pre_call\x18\x02 \x03(\x0b\x32:.google.cloud.tools.snippetgen.configlanguage.v1.Statement\x1a\xe7\x01\n\x1bSimpleRequestInitialization\x12^\n\x1apre_request_initialization\x18\x01 \x03(\x0b\x32:.google.cloud.tools.snippetgen.configlanguage.v1.Statement\x12R\n\rrequest_value\x18\x02 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x12\x14\n\x0crequest_name\x18\x03 \x01(\t\x1a\xe1\x02\n\x1eStreamingRequestInitialization\x12u\n\x17\x66irst_streaming_request\x18\x01 \x01(\x0b\x32T.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.SimpleRequestInitialization\x12W\n\titeration\x18\x03 \x01(\x0b\x32\x44.google.cloud.tools.snippetgen.configlanguage.v1.Statement.Iteration\x12o\n\x11streaming_request\x18\x04 \x01(\x0b\x32T.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.SimpleRequestInitialization\x1a/\n\x16SimpleResponseHandling\x12\x15\n\rresponse_name\x18\x01 \x01(\t\x1a\xec\x07\n\x19PaginatedResponseHandling\x12\x15\n\rresponse_name\x18\x01 \x01(\t\x12l\n\x07\x62y_item\x18\x02 \x01(\x0b\x32Y.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.PaginatedResponseHandling.ByItemH\x00\x12l\n\x07\x62y_page\x18\x03 \x01(\x0b\x32Y.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.PaginatedResponseHandling.ByPageH\x00\x12{\n\x0fnext_page_token\x18\x04 \x01(\x0b\x32`.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.PaginatedResponseHandling.NextPageTokenH\x00\x1at\n\x06\x42yItem\x12\x11\n\titem_name\x18\x01 \x01(\t\x12W\n\x13per_item_statements\x18\x02 \x03(\x0b\x32:.google.cloud.tools.snippetgen.configlanguage.v1.Statement\x1a\xe0\x01\n\x06\x42yPage\x12\x11\n\tpage_name\x18\x01 \x01(\t\x12W\n\x13per_page_statements\x18\x02 \x03(\x0b\x32:.google.cloud.tools.snippetgen.configlanguage.v1.Statement\x12j\n\x07\x62y_item\x18\x03 \x01(\x0b\x32Y.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.PaginatedResponseHandling.ByItem\x1a\xf2\x01\n\rNextPageToken\x12\x1c\n\x14next_page_token_name\x18\x01 \x01(\t\x12W\n\x12\x65xplicit_page_size\x18\x02 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x12j\n\x07\x62y_page\x18\x03 \x01(\x0b\x32Y.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.PaginatedResponseHandling.ByPageB\x11\n\x0fpagination_kind\x1a\xcf\x02\n\x13LroResponseHandling\x12\x15\n\rresponse_name\x18\x01 \x01(\t\x12n\n\x0cpolling_type\x18\x02 \x01(\x0e\x32X.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.LroResponseHandling.PollingType\x12\x1d\n\x15polling_response_name\x18\x03 \x01(\t\x12Y\n\x0cpolling_call\x18\x04 \x01(\x0b\x32\x43.google.cloud.tools.snippetgen.configlanguage.v1.Snippet.ClientCall\"7\n\x0bPollingType\x12\x14\n\x10UNTIL_COMPLETION\x10\x00\x12\x08\n\x04ONCE\x10\x01\x12\x08\n\x04NONE\x10\x02\x1a\x9e\x01\n\x19StreamingResponseHandling\x12\x1d\n\x15\x63urrent_response_name\x18\x01 \x01(\t\x12\x62\n\x1eper_stream_response_statements\x18\x02 \x03(\x0b\x32:.google.cloud.tools.snippetgen.configlanguage.v1.StatementB\x06\n\x04\x63\x61ll\"\xc5\x18\n\tStatement\x12]\n\x0b\x64\x65\x63laration\x18\x01 \x01(\x0b\x32\x46.google.cloud.tools.snippetgen.configlanguage.v1.Statement.DeclarationH\x00\x12\x64\n\x0fstandard_output\x18\x02 \x01(\x0b\x32I.google.cloud.tools.snippetgen.configlanguage.v1.Statement.StandardOutputH\x00\x12S\n\x06return\x18\x03 \x01(\x0b\x32\x41.google.cloud.tools.snippetgen.configlanguage.v1.Statement.ReturnH\x00\x12]\n\x0b\x63onditional\x18\x04 \x01(\x0b\x32\x46.google.cloud.tools.snippetgen.configlanguage.v1.Statement.ConditionalH\x00\x12Y\n\titeration\x18\x05 \x01(\x0b\x32\x44.google.cloud.tools.snippetgen.configlanguage.v1.Statement.IterationH\x00\x1a\xc1\x01\n\x0b\x44\x65\x63laration\x12\x43\n\x04type\x18\x01 \x01(\x0b\x32\x35.google.cloud.tools.snippetgen.configlanguage.v1.Type\x12\x0c\n\x04name\x18\x02 \x01(\t\x12J\n\x05value\x18\x03 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x12\x13\n\x0b\x64\x65scription\x18\x04 \x01(\t\x1a\\\n\x0eStandardOutput\x12J\n\x05value\x18\x02 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x1aU\n\x06Return\x12K\n\x06result\x18\x01 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x1a\xf8\x01\n\x0b\x43onditional\x12N\n\tcondition\x18\x01 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x12K\n\x07on_true\x18\x02 \x03(\x0b\x32:.google.cloud.tools.snippetgen.configlanguage.v1.Statement\x12L\n\x08on_false\x18\x03 \x03(\x0b\x32:.google.cloud.tools.snippetgen.configlanguage.v1.Statement\x1a\xdd\x0f\n\tIteration\x12\x83\x01\n\x1anumeric_sequence_iteration\x18\x01 \x01(\x0b\x32].google.cloud.tools.snippetgen.configlanguage.v1.Statement.Iteration.NumericSequenceIterationH\x00\x12t\n\x12repeated_iteration\x18\x02 \x01(\x0b\x32V.google.cloud.tools.snippetgen.configlanguage.v1.Statement.Iteration.RepeatedIterationH\x00\x12j\n\rmap_iteration\x18\x03 \x01(\x0b\x32Q.google.cloud.tools.snippetgen.configlanguage.v1.Statement.Iteration.MapIterationH\x00\x12n\n\x0f\x62ytes_iteration\x18\x04 \x01(\x0b\x32S.google.cloud.tools.snippetgen.configlanguage.v1.Statement.Iteration.BytesIterationH\x00\x12N\n\nstatements\x18\x05 \x03(\x0b\x32:.google.cloud.tools.snippetgen.configlanguage.v1.Statement\x1a\xdc\x05\n\x18NumericSequenceIteration\x12X\n\x08start_at\x18\x01 \x01(\x0b\x32\x46.google.cloud.tools.snippetgen.configlanguage.v1.Statement.Declaration\x12P\n\tincrement\x18\x03 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionH\x00\x12Q\n\nmultiplier\x18\x04 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionH\x00\x12Y\n\x12less_than_or_equal\x18\x07 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionH\x01\x12P\n\tless_than\x18\x08 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionH\x01\x12\\\n\x15greater_than_or_equal\x18\t \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionH\x01\x12S\n\x0cgreater_than\x18\n \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionH\x01\x12R\n\x0btotal_steps\x18\x0b \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionH\x01\x42\x06\n\x04stepB\x05\n\x03\x65nd\x1a\x8c\x01\n\x11RepeatedIteration\x12\x61\n\x11repeated_elements\x18\x01 \x01(\x0b\x32\x46.google.cloud.tools.snippetgen.configlanguage.v1.Statement.Declaration\x12\x14\n\x0c\x63urrent_name\x18\x02 \x01(\t\x1a\x99\x01\n\x0cMapIteration\x12S\n\x03map\x18\x01 \x01(\x0b\x32\x46.google.cloud.tools.snippetgen.configlanguage.v1.Statement.Declaration\x12\x18\n\x10\x63urrent_key_name\x18\x02 \x01(\t\x12\x1a\n\x12\x63urrent_value_name\x18\x03 \x01(\t\x1a\x8b\x03\n\x0e\x42ytesIteration\x12]\n\rbyte_sequence\x18\x01 \x01(\x0b\x32\x46.google.cloud.tools.snippetgen.configlanguage.v1.Statement.Declaration\x12Q\n\nchunk_size\x18\x02 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionH\x00\x12S\n\x0ctotal_chunks\x18\x03 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionH\x00\x12S\n\nchunk_type\x18\x04 \x01(\x0b\x32?.google.cloud.tools.snippetgen.configlanguage.v1.Type.BytesType\x12\x14\n\x0c\x63urrent_name\x18\x05 \x01(\tB\x07\n\x05\x63hunkB\x10\n\x0eiteration_typeB\x10\n\x0estatement_type\"\xb6\r\n\x04Type\x12W\n\x0bscalar_type\x18\x01 \x01(\x0e\x32@.google.cloud.tools.snippetgen.configlanguage.v1.Type.ScalarTypeH\x00\x12S\n\tenum_type\x18\x02 \x01(\x0b\x32>.google.cloud.tools.snippetgen.configlanguage.v1.Type.EnumTypeH\x00\x12U\n\nbytes_type\x18\x03 \x01(\x0b\x32?.google.cloud.tools.snippetgen.configlanguage.v1.Type.BytesTypeH\x00\x12Y\n\x0cmessage_type\x18\x04 \x01(\x0b\x32\x41.google.cloud.tools.snippetgen.configlanguage.v1.Type.MessageTypeH\x00\x12[\n\rrepeated_type\x18\x05 \x01(\x0b\x32\x42.google.cloud.tools.snippetgen.configlanguage.v1.Type.RepeatedTypeH\x00\x12Q\n\x08map_type\x18\x06 \x01(\x0b\x32=.google.cloud.tools.snippetgen.configlanguage.v1.Type.MapTypeH\x00\x1a\"\n\x08\x45numType\x12\x16\n\x0e\x65num_full_name\x18\x01 \x01(\t\x1a\xce\x01\n\tBytesType\x12o\n\x13language_equivalent\x18\x01 \x01(\x0e\x32R.google.cloud.tools.snippetgen.configlanguage.v1.Type.BytesType.LanguageEquivalent\"P\n\x12LanguageEquivalent\x12\x12\n\x0ePROTOBUF_BYTES\x10\x00\x12\n\n\x06\x42\x41SE64\x10\x01\x12\x0e\n\nBYTE_ARRAY\x10\x02\x12\n\n\x06STREAM\x10\x03\x1a(\n\x0bMessageType\x12\x19\n\x11message_full_name\x18\x01 \x01(\t\x1a\x91\x02\n\x0cRepeatedType\x12K\n\x0c\x65lement_type\x18\x01 \x01(\x0b\x32\x35.google.cloud.tools.snippetgen.configlanguage.v1.Type\x12r\n\x13language_equivalent\x18\x02 \x01(\x0e\x32U.google.cloud.tools.snippetgen.configlanguage.v1.Type.RepeatedType.LanguageEquivalent\"@\n\x12LanguageEquivalent\x12\x15\n\x11PROTOBUF_REPEATED\x10\x00\x12\t\n\x05\x41RRAY\x10\x01\x12\x08\n\x04LIST\x10\x02\x1a\xc4\x02\n\x07MapType\x12G\n\x08key_type\x18\x01 \x01(\x0b\x32\x35.google.cloud.tools.snippetgen.configlanguage.v1.Type\x12I\n\nvalue_type\x18\x02 \x01(\x0b\x32\x35.google.cloud.tools.snippetgen.configlanguage.v1.Type\x12m\n\x13language_equivalent\x18\x03 \x01(\x0e\x32P.google.cloud.tools.snippetgen.configlanguage.v1.Type.MapType.LanguageEquivalent\"6\n\x12LanguageEquivalent\x12\x10\n\x0cPROTOBUF_MAP\x10\x00\x12\x0e\n\nDICTIONARY\x10\x01\"\x96\x02\n\nScalarType\x12\x19\n\x15SCALAR_TYPE_UNDEFINED\x10\x00\x12\x0f\n\x0bTYPE_DOUBLE\x10\x01\x12\x0e\n\nTYPE_FLOAT\x10\x02\x12\x0e\n\nTYPE_INT64\x10\x03\x12\x0f\n\x0bTYPE_UINT64\x10\x04\x12\x0e\n\nTYPE_INT32\x10\x05\x12\x10\n\x0cTYPE_FIXED64\x10\x06\x12\x10\n\x0cTYPE_FIXED32\x10\x07\x12\r\n\tTYPE_BOOL\x10\x08\x12\x0f\n\x0bTYPE_STRING\x10\t\x12\x0f\n\x0bTYPE_UINT32\x10\r\x12\x11\n\rTYPE_SFIXED32\x10\x0f\x12\x11\n\rTYPE_SFIXED64\x10\x10\x12\x0f\n\x0bTYPE_SINT32\x10\x11\x12\x0f\n\x0bTYPE_SINT64\x10\x12\x42\x0b\n\ttype_kind\"\xa8\x10\n\nExpression\x12[\n\nnull_value\x18\x01 \x01(\x0e\x32\x45.google.cloud.tools.snippetgen.configlanguage.v1.Expression.NullValueH\x00\x12\x61\n\rdefault_value\x18\x02 \x01(\x0e\x32H.google.cloud.tools.snippetgen.configlanguage.v1.Expression.DefaultValueH\x00\x12[\n\nname_value\x18\x03 \x01(\x0b\x32\x45.google.cloud.tools.snippetgen.configlanguage.v1.Expression.NameValueH\x00\x12\x16\n\x0cnumber_value\x18\x04 \x01(\x01H\x00\x12\x17\n\rboolean_value\x18\x05 \x01(\x08H\x00\x12\x16\n\x0cstring_value\x18\x06 \x01(\tH\x00\x12\x14\n\nenum_value\x18\x07 \x01(\tH\x00\x12]\n\x0b\x62ytes_value\x18\x08 \x01(\x0b\x32\x46.google.cloud.tools.snippetgen.configlanguage.v1.Expression.BytesValueH\x00\x12\x61\n\rcomplex_value\x18\t \x01(\x0b\x32H.google.cloud.tools.snippetgen.configlanguage.v1.Expression.ComplexValueH\x00\x12_\n\nlist_value\x18\n \x01(\x0b\x32I.google.cloud.tools.snippetgen.configlanguage.v1.Expression.RepeatedValueH\x00\x12Y\n\tmap_value\x18\x0b \x01(\x0b\x32\x44.google.cloud.tools.snippetgen.configlanguage.v1.Expression.MapValueH\x00\x12l\n\x11\x63onditional_value\x18\x0c \x01(\x0b\x32O.google.cloud.tools.snippetgen.configlanguage.v1.Expression.ConditionalOperatorH\x00\x12\x13\n\x0b\x64\x65scription\x18\r \x01(\t\x1a\'\n\tNameValue\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x03(\t\x1a\xb3\x02\n\nBytesValue\x12T\n\rbase64_string\x18\x01 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionH\x00\x12h\n\x0b\x66ile_stream\x18\x02 \x01(\x0b\x32Q.google.cloud.tools.snippetgen.configlanguage.v1.Expression.BytesValue.FileStreamH\x00\x1a\\\n\nFileStream\x12N\n\tfile_path\x18\x01 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.ExpressionB\x07\n\x05value\x1a\xec\x01\n\x0c\x43omplexValue\x12l\n\nproperties\x18\x01 \x03(\x0b\x32X.google.cloud.tools.snippetgen.configlanguage.v1.Expression.ComplexValue.PropertiesEntry\x1an\n\x0fPropertiesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12J\n\x05value\x18\x02 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression:\x02\x38\x01\x1a\\\n\rRepeatedValue\x12K\n\x06values\x18\x01 \x03(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x1a\xa2\x01\n\x08MapValue\x12I\n\x04keys\x18\x01 \x03(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x12K\n\x06values\x18\x02 \x03(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x1a\x82\x02\n\x13\x43onditionalOperator\x12N\n\tcondition\x18\x01 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x12L\n\x07on_true\x18\x02 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\x12M\n\x08on_false\x18\x03 \x01(\x0b\x32;.google.cloud.tools.snippetgen.configlanguage.v1.Expression\"\x1b\n\tNullValue\x12\x0e\n\nNULL_VALUE\x10\x00\"!\n\x0c\x44\x65\x66\x61ultValue\x12\x11\n\rDEFAULT_VALUE\x10\x00\x42\x07\n\x05value*\xa3\x01\n\x17GeneratorOutputLanguage\x12)\n%GENERATOR_OUTPUT_LANGUAGE_UNSPECIFIED\x10\x00\x12\x0f\n\x0b\x43_PLUS_PLUS\x10\x01\x12\x0b\n\x07\x43_SHARP\x10\x02\x12\x06\n\x02GO\x10\x03\x12\x08\n\x04JAVA\x10\x04\x12\x0e\n\nJAVASCRIPT\x10\x05\x12\x07\n\x03PHP\x10\x06\x12\n\n\x06PYTHON\x10\x07\x12\x08\n\x04RUBY\x10\x08\x42\xee\x01\n3com.google.cloud.tools.snippetgen.configlanguage.v1B\x1aSnippetConfigLanguageProtoP\x01\xaa\x02/Google.Cloud.Tools.SnippetGen.ConfigLanguage.V1\xca\x02/Google\\Cloud\\Tools\\SnippetGen\\ConfigLanguage\\V1\xea\x02\x34Google::Cloud::Tools::SnippetGen::ConfigLanguage::V1b\x06proto3') + +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) +_builder.BuildTopDescriptorsAndMessages( + DESCRIPTOR, 'snippet_config_language_pb2', globals()) +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'\n3com.google.cloud.tools.snippetgen.configlanguage.v1B\032SnippetConfigLanguageProtoP\001\252\002/Google.Cloud.Tools.SnippetGen.ConfigLanguage.V1\312\002/Google\\Cloud\\Tools\\SnippetGen\\ConfigLanguage\\V1\352\0024Google::Cloud::Tools::SnippetGen::ConfigLanguage::V1' + _EXPRESSION_COMPLEXVALUE_PROPERTIESENTRY._options = None + _EXPRESSION_COMPLEXVALUE_PROPERTIESENTRY._serialized_options = b'8\001' + _GENERATOROUTPUTLANGUAGE._serialized_start = 13778 + _GENERATOROUTPUTLANGUAGE._serialized_end = 13941 + _SNIPPETCONFIG._serialized_start = 117 + _SNIPPETCONFIG._serialized_end = 450 + _SNIPPETCONFIGMETADATA._serialized_start = 453 + _SNIPPETCONFIGMETADATA._serialized_end = 664 + _RPC._serialized_start = 666 + _RPC._serialized_end = 755 + _SNIPPETSIGNATURE._serialized_start = 758 + _SNIPPETSIGNATURE._serialized_end = 1167 + _SNIPPETSIGNATURE_SYNCPREFERENCE._serialized_start = 1082 + _SNIPPETSIGNATURE_SYNCPREFERENCE._serialized_end = 1167 + _SNIPPET._serialized_start = 1170 + _SNIPPET._serialized_end = 6819 + _SNIPPET_CLIENTINITIALIZATION._serialized_start = 1941 + _SNIPPET_CLIENTINITIALIZATION._serialized_end = 2452 + _SNIPPET_CLIENTINITIALIZATION_SERVICEENDPOINT._serialized_start = 2189 + _SNIPPET_CLIENTINITIALIZATION_SERVICEENDPOINT._serialized_end = 2452 + _SNIPPET_CLIENTINITIALIZATION_SERVICEENDPOINT_SERVICEENDPOINTSCHEMA._serialized_start = 2386 + _SNIPPET_CLIENTINITIALIZATION_SERVICEENDPOINT_SERVICEENDPOINTSCHEMA._serialized_end = 2452 + _SNIPPET_STANDARD._serialized_start = 2455 + _SNIPPET_STANDARD._serialized_end = 2774 + _SNIPPET_PAGINATED._serialized_start = 2777 + _SNIPPET_PAGINATED._serialized_end = 3111 + _SNIPPET_LRO._serialized_start = 3114 + _SNIPPET_LRO._serialized_end = 3420 + _SNIPPET_CLIENTSTREAMING._serialized_start = 3423 + _SNIPPET_CLIENTSTREAMING._serialized_end = 3795 + _SNIPPET_SERVERSTREAMING._serialized_start = 3798 + _SNIPPET_SERVERSTREAMING._serialized_end = 4170 + _SNIPPET_BIDISTREAMING._serialized_start = 4173 + _SNIPPET_BIDISTREAMING._serialized_end = 4574 + _SNIPPET_CLIENTCALL._serialized_start = 4576 + _SNIPPET_CLIENTCALL._serialized_end = 4666 + _SNIPPET_SIMPLEREQUESTINITIALIZATION._serialized_start = 4669 + _SNIPPET_SIMPLEREQUESTINITIALIZATION._serialized_end = 4900 + _SNIPPET_STREAMINGREQUESTINITIALIZATION._serialized_start = 4903 + _SNIPPET_STREAMINGREQUESTINITIALIZATION._serialized_end = 5256 + _SNIPPET_SIMPLERESPONSEHANDLING._serialized_start = 5258 + _SNIPPET_SIMPLERESPONSEHANDLING._serialized_end = 5305 + _SNIPPET_PAGINATEDRESPONSEHANDLING._serialized_start = 5308 + _SNIPPET_PAGINATEDRESPONSEHANDLING._serialized_end = 6312 + _SNIPPET_PAGINATEDRESPONSEHANDLING_BYITEM._serialized_start = 5705 + _SNIPPET_PAGINATEDRESPONSEHANDLING_BYITEM._serialized_end = 5821 + _SNIPPET_PAGINATEDRESPONSEHANDLING_BYPAGE._serialized_start = 5824 + _SNIPPET_PAGINATEDRESPONSEHANDLING_BYPAGE._serialized_end = 6048 + _SNIPPET_PAGINATEDRESPONSEHANDLING_NEXTPAGETOKEN._serialized_start = 6051 + _SNIPPET_PAGINATEDRESPONSEHANDLING_NEXTPAGETOKEN._serialized_end = 6293 + _SNIPPET_LRORESPONSEHANDLING._serialized_start = 6315 + _SNIPPET_LRORESPONSEHANDLING._serialized_end = 6650 + _SNIPPET_LRORESPONSEHANDLING_POLLINGTYPE._serialized_start = 6595 + _SNIPPET_LRORESPONSEHANDLING_POLLINGTYPE._serialized_end = 6650 + _SNIPPET_STREAMINGRESPONSEHANDLING._serialized_start = 6653 + _SNIPPET_STREAMINGRESPONSEHANDLING._serialized_end = 6811 + _STATEMENT._serialized_start = 6822 + _STATEMENT._serialized_end = 9963 + _STATEMENT_DECLARATION._serialized_start = 7304 + _STATEMENT_DECLARATION._serialized_end = 7497 + _STATEMENT_STANDARDOUTPUT._serialized_start = 7499 + _STATEMENT_STANDARDOUTPUT._serialized_end = 7591 + _STATEMENT_RETURN._serialized_start = 7593 + _STATEMENT_RETURN._serialized_end = 7678 + _STATEMENT_CONDITIONAL._serialized_start = 7681 + _STATEMENT_CONDITIONAL._serialized_end = 7929 + _STATEMENT_ITERATION._serialized_start = 7932 + _STATEMENT_ITERATION._serialized_end = 9945 + _STATEMENT_ITERATION_NUMERICSEQUENCEITERATION._serialized_start = 8498 + _STATEMENT_ITERATION_NUMERICSEQUENCEITERATION._serialized_end = 9230 + _STATEMENT_ITERATION_REPEATEDITERATION._serialized_start = 9233 + _STATEMENT_ITERATION_REPEATEDITERATION._serialized_end = 9373 + _STATEMENT_ITERATION_MAPITERATION._serialized_start = 9376 + _STATEMENT_ITERATION_MAPITERATION._serialized_end = 9529 + _STATEMENT_ITERATION_BYTESITERATION._serialized_start = 9532 + _STATEMENT_ITERATION_BYTESITERATION._serialized_end = 9927 + _TYPE._serialized_start = 9966 + _TYPE._serialized_end = 11684 + _TYPE_ENUMTYPE._serialized_start = 10502 + _TYPE_ENUMTYPE._serialized_end = 10536 + _TYPE_BYTESTYPE._serialized_start = 10539 + _TYPE_BYTESTYPE._serialized_end = 10745 + _TYPE_BYTESTYPE_LANGUAGEEQUIVALENT._serialized_start = 10665 + _TYPE_BYTESTYPE_LANGUAGEEQUIVALENT._serialized_end = 10745 + _TYPE_MESSAGETYPE._serialized_start = 10747 + _TYPE_MESSAGETYPE._serialized_end = 10787 + _TYPE_REPEATEDTYPE._serialized_start = 10790 + _TYPE_REPEATEDTYPE._serialized_end = 11063 + _TYPE_REPEATEDTYPE_LANGUAGEEQUIVALENT._serialized_start = 10999 + _TYPE_REPEATEDTYPE_LANGUAGEEQUIVALENT._serialized_end = 11063 + _TYPE_MAPTYPE._serialized_start = 11066 + _TYPE_MAPTYPE._serialized_end = 11390 + _TYPE_MAPTYPE_LANGUAGEEQUIVALENT._serialized_start = 11336 + _TYPE_MAPTYPE_LANGUAGEEQUIVALENT._serialized_end = 11390 + _TYPE_SCALARTYPE._serialized_start = 11393 + _TYPE_SCALARTYPE._serialized_end = 11671 + _EXPRESSION._serialized_start = 11687 + _EXPRESSION._serialized_end = 13775 + _EXPRESSION_NAMEVALUE._serialized_start = 12594 + _EXPRESSION_NAMEVALUE._serialized_end = 12633 + _EXPRESSION_BYTESVALUE._serialized_start = 12636 + _EXPRESSION_BYTESVALUE._serialized_end = 12943 + _EXPRESSION_BYTESVALUE_FILESTREAM._serialized_start = 12842 + _EXPRESSION_BYTESVALUE_FILESTREAM._serialized_end = 12934 + _EXPRESSION_COMPLEXVALUE._serialized_start = 12946 + _EXPRESSION_COMPLEXVALUE._serialized_end = 13182 + _EXPRESSION_COMPLEXVALUE_PROPERTIESENTRY._serialized_start = 13072 + _EXPRESSION_COMPLEXVALUE_PROPERTIESENTRY._serialized_end = 13182 + _EXPRESSION_REPEATEDVALUE._serialized_start = 13184 + _EXPRESSION_REPEATEDVALUE._serialized_end = 13276 + _EXPRESSION_MAPVALUE._serialized_start = 13279 + _EXPRESSION_MAPVALUE._serialized_end = 13441 + _EXPRESSION_CONDITIONALOPERATOR._serialized_start = 13444 + _EXPRESSION_CONDITIONALOPERATOR._serialized_end = 13702 + _EXPRESSION_NULLVALUE._serialized_start = 13704 + _EXPRESSION_NULLVALUE._serialized_end = 13731 + _EXPRESSION_DEFAULTVALUE._serialized_start = 13733 + _EXPRESSION_DEFAULTVALUE._serialized_end = 13766 +# @@protoc_insertion_point(module_scope) diff --git a/tests/configurable_snippetgen/resources/README.md b/tests/configurable_snippetgen/resources/README.md new file mode 100644 index 0000000000..53bd169411 --- /dev/null +++ b/tests/configurable_snippetgen/resources/README.md @@ -0,0 +1,38 @@ +# Resources for testing Configurable SnippetGen + +Each subdirectory should correspond to an API and contain three types of files. For example: + +``` +. +├── README.md +└── speech + ├── request.desc + ├── speech_createCustomClass.json + └── speech_v1_generated_adaptation_create_custom_class_basic_async.py +``` + +### `request.desc`: + +This is a copy of the CodeGeneratorRequest message used by the GAPIC generator. To generate it: + +1. Install `protoc`. +1. Install [gapic-generator-python](https://github.com/googleapis/gapic-generator-python). +1. Run the following command from the root of a local copy of [googleapis](https://github.com/googleapis/googleapis): + + ``` + API=speech + VERSION=v1 + + protoc google/cloud/$API/$VERSION/*.proto \ + --experimental_allow_proto3_optional \ + --proto_path=. \ + --dump_out=. + ``` + +### Snippet config files + +Handwritten json file containing the configuration of a code snippet. Each config file typically represents both `sync` and `async` Python snippets, and could specify more than one API version. + +### Golden files + +One or more expected snippet for each config file. diff --git a/tests/configurable_snippetgen/resources/speech/request.desc b/tests/configurable_snippetgen/resources/speech/request.desc new file mode 100644 index 0000000000..44518c7599 Binary files /dev/null and b/tests/configurable_snippetgen/resources/speech/request.desc differ diff --git a/tests/configurable_snippetgen/resources/speech/speech_createCustomClass.json b/tests/configurable_snippetgen/resources/speech/speech_createCustomClass.json new file mode 100644 index 0000000000..a86d14c521 --- /dev/null +++ b/tests/configurable_snippetgen/resources/speech/speech_createCustomClass.json @@ -0,0 +1,179 @@ +{ + "metadata": { + "configId": "Basic", + "snippetName": "Custom Class Creation", + "snippetDescription": "Shows how to create a custom class" + }, + "rpc": { + "protoPackage": "google.cloud.speech", + "apiVersion": [ + "v1" + ], + "serviceName": "Adaptation", + "rpcName": "CreateCustomClass" + }, + "signature": { + "snippetMethodName": "create_custom_class", + "returnType": { + "messageType": { + "messageFullName": "google.cloud.speech.v1.CustomClass" + } + }, + "syncPreference": "PREFER_ASYNC", + "parameters": [ + { + "type": { + "scalarType": "TYPE_STRING" + }, + "name": "parent", + "value": { + "stringValue": "projects/[PROJECT]/locations/us" + }, + "description": "The custom class parent element" + }, + { + "type": { + "scalarType": "TYPE_STRING" + }, + "name": "custom_class_id", + "value": { + "stringValue": "passengerships" + }, + "description": "The id for the custom class" + } + ] + }, + "snippet": { + "serviceClientInitialization": { + "customServiceEndpoint": { + "schema": "HTTPS", + "host": "speech.googleapis.com", + "region": "us" + } + }, + "standard": { + "requestInitialization": { + "requestValue": { + "complexValue": { + "properties": { + "parent": { + "nameValue": { + "name": "parent" + } + }, + "custom_class_id": { + "nameValue": { + "name": "custom_class_id" + } + }, + "custom_class": { + "complexValue": { + "properties": { + "items": { + "listValue": { + "values": [ + { + "stringValue": "Titanic" + }, + { + "stringValue": "RMS Queen Mary" + } + ] + } + } + } + } + } + } + } + }, + "requestName": "create_custom_class_request" + }, + "call": { + "preCall": [ + { + "standardOutput": { + "value": { + "stringValue": "Calling the CreateCustomClass operation." + } + } + } + ] + }, + "responseHandling": { + "responseName": "created_custom_class" + } + }, + "finalStatements": [ + { + "standardOutput": { + "value": { + "stringValue": "A Custom Class with the following name has been created." + } + } + }, + { + "standardOutput": { + "value": { + "nameValue": { + "name": "created_custom_class", + "path": ["name"] + } + } + } + }, + { + "standardOutput": { + "value": { + "stringValue": "The Custom class contains the following items." + } + } + }, + { + "iteration": { + "repeatedIteration": { + "repeatedElements": { + "type": { + "repeatedType": { + "elementType": { + "messageType": { + "messageFullName": "google.cloud.speech.v1.CustomClass.ClassItem" + } + } + } + }, + "name": "items_list", + "value": { + "nameValue": { + "name": "created_custom_class", + "path": ["items"] + } + } + }, + "currentName": "item" + }, + "statements": [ + { + "standardOutput": { + "value": { + "nameValue": { + "name": "item" + } + } + } + } + ] + } + }, + { + "return": { + "result": { + "nameValue": { + "name": "created_custom_class" + } + } + } + } + ] + } + } diff --git a/tests/configurable_snippetgen/resources/speech/speech_v1_generated_adaptation_create_custom_class_basic_async.py b/tests/configurable_snippetgen/resources/speech/speech_v1_generated_adaptation_create_custom_class_basic_async.py new file mode 100644 index 0000000000..82c3010f3a --- /dev/null +++ b/tests/configurable_snippetgen/resources/speech/speech_v1_generated_adaptation_create_custom_class_basic_async.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-speech + +# [START speech_v1_generated_Adaptation_CreateCustomClass_Basic_async] +from google.cloud import speech_v1 + + +async def sample_create_custom_class_basic( + parent: str = "projects/[PROJECT]/locations/us", + custom_class_id: str = "passengerships", +) -> speech_v1.CustomClass: + """Custom Class Creation. + + Shows how to create a custom class. + + Args: + parent: The custom class parent element + custom_class_id: The id for the custom class + + Returns: + a CustomClass + """ + client = speech_v1.AdaptationAsyncClient( + client_options={"api_endpoint": "https://us-speech.googleapis.com"} + ) + + request = speech_v1.CreateCustomClassRequest( + parent=parent, + custom_class_id=custom_class_id, + custom_class=speech_v1.CustomClass( + items=[ + speech_v1.CustomClass.ClassItem(value="Titanic"), + speech_v1.CustomClass.ClassItem(value="RMS Queen Mary"), + ] + ), + ) + + print("Calling the CreateCustomClass operation.") + response = await client.create_custom_class(request=request) + created_custom_class = response.result() + + print("A Custom Class with the following name has been created.") + print(created_custom_class.name) + + print("The Custom class contains the following items.") + items_list = created_custom_class.items + for item in items_list: + print(item) + + return created_custom_class + + +# [END speech_v1_generated_Adaptation_CreateCustomClass_Basic_async] diff --git a/tests/configurable_snippetgen/test_resources.py b/tests/configurable_snippetgen/test_resources.py new file mode 100644 index 0000000000..ce0720574c --- /dev/null +++ b/tests/configurable_snippetgen/test_resources.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from pathlib import Path + +from google.protobuf.compiler import plugin_pb2 +import pytest + +from gapic import utils +from gapic.schema import api + + +CURRENT_DIRECTORY = Path(__file__).parent.absolute() +SPEECH_V1_REQUEST_PATH = (CURRENT_DIRECTORY / + "resources" / "speech" / "request.desc") + + +def test_request(): + with open(SPEECH_V1_REQUEST_PATH, "rb") as f: + req = plugin_pb2.CodeGeneratorRequest.FromString(f.read()) + + # From gapic/cli/generator.py. + opts = utils.Options.build(req.parameter) + api_schema = api.API.build( + req.proto_file, + opts=opts, + package="google.cloud.speech.v1", + ) + + expected_services = [ + "google.cloud.speech.v1.Adaptation", + "google.cloud.speech.v1.Speech", + ] + + # We are only making sure that the dumped request.desc file can be + # successfully loaded to rebuild API schema. + assert list(api_schema.services.keys()) == expected_services