diff --git a/generator/README.md b/generator/README.md index 75e97a35d..1a2d9bd16 100644 --- a/generator/README.md +++ b/generator/README.md @@ -13,13 +13,13 @@ go run ./devtools/cmd/generate -language=rust Alternatively, you can run the protoc command directly: ```bash -go install github.com/googleapis/google-cloud-rust/generator/cmd/protoc-gen-gclient -protoc -I cmd/protoc-gen-gclient/testdata/smprotos \ - -I /path/to/googleapis \ +go install ./cmd/protoc-gen-gclient + +protoc -I testdata/googleapis \ --gclient_out=. \ --gclient_opt=capture-input=true,language=rust \ - cmd/protoc-gen-gclient/testdata/smprotos/resources.proto \ - cmd/protoc-gen-gclient/testdata/smprotos/service.proto + testdata/googleapis/google/cloud/secretmanager/v1/resources.proto \ + testdata/googleapis/google/cloud/secretmanager/v1/service.proto ``` or to playback an old input without the need for `protoc`: diff --git a/generator/cmd/openapi/main_test.go b/generator/cmd/openapi/main_test.go index d5423da97..cf540a243 100644 --- a/generator/cmd/openapi/main_test.go +++ b/generator/cmd/openapi/main_test.go @@ -26,7 +26,13 @@ func TestMain(m *testing.M) { } func TestRun_Rust(t *testing.T) { - if err := run("testdata/secretmanager_openapi_v1.json", "rust", "testdata/rust/golden", "../../templates"); err != nil { + const ( + inputPath = "../../testdata/openapi/secretmanager_openapi_v1.json" + language = "rust" + outDir = "../../testdata/rust/openapi/golden" + templateDir = "../../templates" + ) + if err := run(inputPath, language, outDir, templateDir); err != nil { t.Fatal(err) } } diff --git a/generator/cmd/protoc-gen-gclient/main_test.go b/generator/cmd/protoc-gen-gclient/main_test.go index 1710727df..c750ec3d8 100644 --- a/generator/cmd/protoc-gen-gclient/main_test.go +++ b/generator/cmd/protoc-gen-gclient/main_test.go @@ -26,7 +26,12 @@ func TestMain(m *testing.M) { } func TestRun_Rust(t *testing.T) { - if err := run("testdata/rust/rust.bin", "testdata/rust/golden", "../../templates"); err != nil { + const ( + inputPath = "../../testdata/rust/gclient/rust.bin" + outDir = "../../testdata/rust/gclient/golden" + templateDir = "../../templates" + ) + if err := run(inputPath, outDir, templateDir); err != nil { t.Fatal(err) } } diff --git a/generator/cmd/protoc-gen-gclient/testdata/rust/golden/lib.rs b/generator/cmd/protoc-gen-gclient/testdata/rust/golden/lib.rs deleted file mode 100755 index 6728260c1..000000000 --- a/generator/cmd/protoc-gen-gclient/testdata/rust/golden/lib.rs +++ /dev/null @@ -1,97 +0,0 @@ -use std::sync::Arc; - -pub mod model; - -#[derive(Clone, Debug)] -pub struct Client { - inner: Arc, -} - -#[derive(Debug)] -struct ClientRef { - http_client: reqwest::Client, - token: String, -} - -impl Client { - pub fn new(tok: String) -> Self { - let client = reqwest::Client::builder().build().unwrap(); - let inner = ClientRef { - http_client: client, - token: tok, - }; - Self { - inner: Arc::new(inner), - } - } - - /// Secret Manager Service - /// - /// Manages secrets and operations using those secrets. Implements a REST - /// model with the following objects: - /// - /// * [Secret][google.cloud.secretmanager.v1.Secret] - /// * [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] - pub fn secret_manager_service(&self) -> SecretManagerService { - SecretManagerService { - client: self.clone(), - base_path: "https://secretmanager.googleapis.com/".to_string(), - } - } -} - -/// Secret Manager Service -/// -/// Manages secrets and operations using those secrets. Implements a REST -/// model with the following objects: -/// -/// * [Secret][google.cloud.secretmanager.v1.Secret] -/// * [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] -#[derive(Debug)] -pub struct SecretManagerService { - client: Client, - base_path: String, -} - -impl SecretManagerService { - - /// Creates a new [Secret][google.cloud.secretmanager.v1.Secret] containing no - /// [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - pub async fn create_secret(&self, req: model::CreateSecretRequest) -> Result> { - let client = self.client.inner.clone(); - let res = client.http_client - .post(format!( - "{}/v1/{}/secrets", - self.base_path, - req.parent, - )) - .query(&[("alt", "json")]) - .query(&[("secretId", req.secret_id.as_str())]) - .bearer_auth(&client.token) - .json(&req.secret) - .send().await?; - if !res.status().is_success() { - return Err("sorry the api you are looking for is not available, please try again".into()); - } - res.json::.await? - } - - /// Gets metadata for a given [Secret][google.cloud.secretmanager.v1.Secret]. - pub async fn get_secret(&self, req: model::GetSecretRequest) -> Result> { - let client = self.client.inner.clone(); - let res = client.http_client - .get(format!( - "{}/v1/{}", - self.base_path, - req.name, - )) - .query(&[("alt", "json")]) - .query(&[("name", req.name.as_str())]) - .bearer_auth(&client.token) - .send().await?; - if !res.status().is_success() { - return Err("sorry the api you are looking for is not available, please try again".into()); - } - res.json::.await? - } -} diff --git a/generator/cmd/protoc-gen-gclient/testdata/rust/golden/model.rs b/generator/cmd/protoc-gen-gclient/testdata/rust/golden/model.rs deleted file mode 100755 index 7365445a1..000000000 --- a/generator/cmd/protoc-gen-gclient/testdata/rust/golden/model.rs +++ /dev/null @@ -1,498 +0,0 @@ -#![allow(dead_code)] - -use serde::{Deserialize, Serialize}; - - -/// A [Secret][google.cloud.secretmanager.v1.Secret] is a logical secret whose -/// value and versions can be accessed. -/// -/// A [Secret][google.cloud.secretmanager.v1.Secret] is made up of zero or more -/// [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] that represent -/// the secret data. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct Secret { - - /// Output only. The resource name of the - /// [Secret][google.cloud.secretmanager.v1.Secret] in the format - /// `projects/*/secrets/*`. - pub name: String, - - /// Optional. Immutable. The replication policy of the secret data attached to - /// the [Secret][google.cloud.secretmanager.v1.Secret]. - /// - /// The replication policy cannot be changed after the Secret has been created. - pub replication: Option, - - /// Output only. The time at which the - /// [Secret][google.cloud.secretmanager.v1.Secret] was created. - pub create_time: Option, - - /// The labels assigned to this Secret. - /// - /// Label keys must be between 1 and 63 characters long, have a UTF-8 encoding - /// of maximum 128 bytes, and must conform to the following PCRE regular - /// expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}` - /// - /// Label values must be between 0 and 63 characters long, have a UTF-8 - /// encoding of maximum 128 bytes, and must conform to the following PCRE - /// regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}` - /// - /// No more than 64 labels can be assigned to a given resource. - pub labels: Option>, - - /// Optional. A list of up to 10 Pub/Sub topics to which messages are published - /// when control plane operations are called on the secret or its versions. - pub topics: Option, - - /// Optional. Timestamp in UTC when the - /// [Secret][google.cloud.secretmanager.v1.Secret] is scheduled to expire. - /// This is always provided on output, regardless of what was sent on input. - pub expire_time: Option, - - /// Input only. The TTL for the - /// [Secret][google.cloud.secretmanager.v1.Secret]. - pub ttl: Option, - - /// Optional. Etag of the currently stored - /// [Secret][google.cloud.secretmanager.v1.Secret]. - pub etag: String, - - /// Optional. Rotation policy attached to the - /// [Secret][google.cloud.secretmanager.v1.Secret]. May be excluded if there is - /// no rotation policy. - pub rotation: Option, - - /// Optional. Mapping from version alias to version name. - /// - /// A version alias is a string with a maximum length of 63 characters and can - /// contain uppercase and lowercase letters, numerals, and the hyphen (`-`) - /// and underscore ('_') characters. An alias string must start with a - /// letter and cannot be the string 'latest' or 'NEW'. - /// No more than 50 aliases can be assigned to a given secret. - /// - /// Version-Alias pairs will be viewable via GetSecret and modifiable via - /// UpdateSecret. Access by alias is only be supported on - /// GetSecretVersion and AccessSecretVersion. - pub version_aliases: Option>, - - /// Optional. Custom metadata about the secret. - /// - /// Annotations are distinct from various forms of labels. - /// Annotations exist to allow client tools to store their own state - /// information without requiring a database. - /// - /// Annotation keys must be between 1 and 63 characters long, have a UTF-8 - /// encoding of maximum 128 bytes, begin and end with an alphanumeric character - /// ([a-z0-9A-Z]), and may have dashes (-), underscores (_), dots (.), and - /// alphanumerics in between these symbols. - /// - /// The total size of annotation keys and values must be less than 16KiB. - pub annotations: Option>, - - /// Optional. Secret Version TTL after destruction request - /// - /// This is a part of the Delayed secret version destroy feature. - /// For secret with TTL>0, version destruction doesn't happen immediately - /// on calling destroy instead the version goes to a disabled state and - /// destruction happens after the TTL expires. - pub version_destroy_ttl: Option, - - /// Optional. The customer-managed encryption configuration of the Regionalised - /// Secrets. If no configuration is provided, Google-managed default encryption - /// is used. - /// - /// Updates to the [Secret][google.cloud.secretmanager.v1.Secret] encryption - /// configuration only apply to - /// [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] added - /// afterwards. They do not apply retroactively to existing - /// [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - pub customer_managed_encryption: Option, -} - -/// A secret version resource in the Secret Manager API. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct SecretVersion { - - /// Output only. The resource name of the - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] in the format - /// `projects/*/secrets/*/versions/*`. - /// - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] IDs in a - /// [Secret][google.cloud.secretmanager.v1.Secret] start at 1 and are - /// incremented for each subsequent version of the secret. - pub name: String, - - /// Output only. The time at which the - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] was created. - pub create_time: Option, - - /// Output only. The time this - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] was destroyed. - /// Only present if [state][google.cloud.secretmanager.v1.SecretVersion.state] - /// is - /// [DESTROYED][google.cloud.secretmanager.v1.SecretVersion.State.DESTROYED]. - pub destroy_time: Option, - - /// Output only. The current state of the - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - pub state: SecretVersion_State, - - /// The replication status of the - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - pub replication_status: Option, - - /// Output only. Etag of the currently stored - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - pub etag: String, - - /// Output only. True if payload checksum specified in - /// [SecretPayload][google.cloud.secretmanager.v1.SecretPayload] object has - /// been received by - /// [SecretManagerService][google.cloud.secretmanager.v1.SecretManagerService] - /// on - /// [SecretManagerService.AddSecretVersion][google.cloud.secretmanager.v1.SecretManagerService.AddSecretVersion]. - pub client_specified_payload_checksum: bool, - - /// Optional. Output only. Scheduled destroy time for secret version. - /// This is a part of the Delayed secret version destroy feature. For a - /// Secret with a valid version destroy TTL, when a secert version is - /// destroyed, the version is moved to disabled state and it is scheduled for - /// destruction. The version is destroyed only after the - /// `scheduled_destroy_time`. - pub scheduled_destroy_time: Option, - - /// Output only. The customer-managed encryption status of the - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Only - /// populated if customer-managed encryption is used and - /// [Secret][google.cloud.secretmanager.v1.Secret] is a Regionalised Secret. - pub customer_managed_encryption: Option, -} - -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct SecretVersion_State(i32); - -impl SecretVersion_State { - - // Not specified. This value is unused and invalid. - pub const SecretVersion_StateUnspecified: SecretVersion_State = SecretVersion_State(0); - - // The [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] may be - // accessed. - pub const SecretVersion_Enabled: SecretVersion_State = SecretVersion_State(1); - - // The [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] may not - // be accessed, but the secret data is still available and can be placed - // back into the - // [ENABLED][google.cloud.secretmanager.v1.SecretVersion.State.ENABLED] - // state. - pub const SecretVersion_Disabled: SecretVersion_State = SecretVersion_State(2); - - // The [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] is - // destroyed and the secret data is no longer stored. A version may not - // leave this state once entered. - pub const SecretVersion_Destroyed: SecretVersion_State = SecretVersion_State(3); -} -/// A policy that defines the replication and encryption configuration of data. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct Replication { - - /// The [Secret][google.cloud.secretmanager.v1.Secret] will automatically be - /// replicated without any restrictions. - pub automatic: Option, - - /// The [Secret][google.cloud.secretmanager.v1.Secret] will only be - /// replicated into the locations specified. - pub user_managed: Option, -} - -/// A replication policy that replicates the -/// [Secret][google.cloud.secretmanager.v1.Secret] payload without any -/// restrictions. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct Replication_Automatic { - - /// Optional. The customer-managed encryption configuration of the - /// [Secret][google.cloud.secretmanager.v1.Secret]. If no configuration is - /// provided, Google-managed default encryption is used. - /// - /// Updates to the [Secret][google.cloud.secretmanager.v1.Secret] encryption - /// configuration only apply to - /// [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] added - /// afterwards. They do not apply retroactively to existing - /// [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - pub customer_managed_encryption: Option, -} - -/// A replication policy that replicates the -/// [Secret][google.cloud.secretmanager.v1.Secret] payload into the locations -/// specified in [Secret.replication.user_managed.replicas][] -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct Replication_UserManaged { - - /// Required. The list of Replicas for this - /// [Secret][google.cloud.secretmanager.v1.Secret]. - /// - /// Cannot be empty. - pub replicas: Option, -} - -/// Represents a Replica for this -/// [Secret][google.cloud.secretmanager.v1.Secret]. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct Replication_UserManaged_Replica { - - /// The canonical IDs of the location to replicate data. - /// For example: `"us-east1"`. - pub location: String, - - /// Optional. The customer-managed encryption configuration of the - /// [User-Managed Replica][Replication.UserManaged.Replica]. If no - /// configuration is provided, Google-managed default encryption is used. - /// - /// Updates to the [Secret][google.cloud.secretmanager.v1.Secret] - /// encryption configuration only apply to - /// [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] added - /// afterwards. They do not apply retroactively to existing - /// [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - pub customer_managed_encryption: Option, -} - -/// Configuration for encrypting secret payloads using customer-managed -/// encryption keys (CMEK). -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct CustomerManagedEncryption { - - /// Required. The resource name of the Cloud KMS CryptoKey used to encrypt - /// secret payloads. - /// - /// For secrets using the - /// [UserManaged][google.cloud.secretmanager.v1.Replication.UserManaged] - /// replication policy type, Cloud KMS CryptoKeys must reside in the same - /// location as the [replica location][Secret.UserManaged.Replica.location]. - /// - /// For secrets using the - /// [Automatic][google.cloud.secretmanager.v1.Replication.Automatic] - /// replication policy type, Cloud KMS CryptoKeys must reside in `global`. - /// - /// The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`. - pub kms_key_name: String, -} - -/// The replication status of a -/// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct ReplicationStatus { - - /// Describes the replication status of a - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] with - /// automatic replication. - /// - /// Only populated if the parent - /// [Secret][google.cloud.secretmanager.v1.Secret] has an automatic - /// replication policy. - pub automatic: Option, - - /// Describes the replication status of a - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] with - /// user-managed replication. - /// - /// Only populated if the parent - /// [Secret][google.cloud.secretmanager.v1.Secret] has a user-managed - /// replication policy. - pub user_managed: Option, -} - -/// The replication status of a -/// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] using -/// automatic replication. -/// -/// Only populated if the parent [Secret][google.cloud.secretmanager.v1.Secret] -/// has an automatic replication policy. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct ReplicationStatus_AutomaticStatus { - - /// Output only. The customer-managed encryption status of the - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Only - /// populated if customer-managed encryption is used. - pub customer_managed_encryption: Option, -} - -/// The replication status of a -/// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] using -/// user-managed replication. -/// -/// Only populated if the parent [Secret][google.cloud.secretmanager.v1.Secret] -/// has a user-managed replication policy. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct ReplicationStatus_UserManagedStatus { - - /// Output only. The list of replica statuses for the - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - pub replicas: Option, -} - -/// Describes the status of a user-managed replica for the -/// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct ReplicationStatus_UserManagedStatus_ReplicaStatus { - - /// Output only. The canonical ID of the replica location. - /// For example: `"us-east1"`. - pub location: String, - - /// Output only. The customer-managed encryption status of the - /// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Only - /// populated if customer-managed encryption is used. - pub customer_managed_encryption: Option, -} - -/// Describes the status of customer-managed encryption. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct CustomerManagedEncryptionStatus { - - /// Required. The resource name of the Cloud KMS CryptoKeyVersion used to - /// encrypt the secret payload, in the following format: - /// `projects/*/locations/*/keyRings/*/cryptoKeys/*/versions/*`. - pub kms_key_version_name: String, -} - -/// A Pub/Sub topic which Secret Manager will publish to when control plane -/// events occur on this secret. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct Topic { - - /// Required. The resource name of the Pub/Sub topic that will be published to, - /// in the following format: `projects/*/topics/*`. For publication to succeed, - /// the Secret Manager service agent must have the `pubsub.topic.publish` - /// permission on the topic. The Pub/Sub Publisher role - /// (`roles/pubsub.publisher`) includes this permission. - pub name: String, -} - -/// The rotation time and period for a -/// [Secret][google.cloud.secretmanager.v1.Secret]. At next_rotation_time, Secret -/// Manager will send a Pub/Sub notification to the topics configured on the -/// Secret. [Secret.topics][google.cloud.secretmanager.v1.Secret.topics] must be -/// set to configure rotation. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct Rotation { - - /// Optional. Timestamp in UTC at which the - /// [Secret][google.cloud.secretmanager.v1.Secret] is scheduled to rotate. - /// Cannot be set to less than 300s (5 min) in the future and at most - /// 3153600000s (100 years). - /// - /// [next_rotation_time][google.cloud.secretmanager.v1.Rotation.next_rotation_time] - /// MUST be set if - /// [rotation_period][google.cloud.secretmanager.v1.Rotation.rotation_period] - /// is set. - pub next_rotation_time: Option, - - /// Input only. The Duration between rotation notifications. Must be in seconds - /// and at least 3600s (1h) and at most 3153600000s (100 years). - /// - /// If - /// [rotation_period][google.cloud.secretmanager.v1.Rotation.rotation_period] - /// is set, - /// [next_rotation_time][google.cloud.secretmanager.v1.Rotation.next_rotation_time] - /// must be set. - /// [next_rotation_time][google.cloud.secretmanager.v1.Rotation.next_rotation_time] - /// will be advanced by this period when the service automatically sends - /// rotation notifications. - pub rotation_period: Option, -} - -/// A secret payload resource in the Secret Manager API. This contains the -/// sensitive secret payload that is associated with a -/// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct SecretPayload { - - /// The secret data. Must be no larger than 64KiB. - pub data: bytes::Bytes, - - /// Optional. If specified, - /// [SecretManagerService][google.cloud.secretmanager.v1.SecretManagerService] - /// will verify the integrity of the received - /// [data][google.cloud.secretmanager.v1.SecretPayload.data] on - /// [SecretManagerService.AddSecretVersion][google.cloud.secretmanager.v1.SecretManagerService.AddSecretVersion] - /// calls using the crc32c checksum and store it to include in future - /// [SecretManagerService.AccessSecretVersion][google.cloud.secretmanager.v1.SecretManagerService.AccessSecretVersion] - /// responses. If a checksum is not provided in the - /// [SecretManagerService.AddSecretVersion][google.cloud.secretmanager.v1.SecretManagerService.AddSecretVersion] - /// request, the - /// [SecretManagerService][google.cloud.secretmanager.v1.SecretManagerService] - /// will generate and store one for you. - /// - /// The CRC32C value is encoded as a Int64 for compatibility, and can be - /// safely downconverted to uint32 in languages that support this type. - /// https://cloud.google.com/apis/design/design_patterns#integer_types - pub data_crc32c: i64, -} - -/// Request message for -/// [SecretManagerService.CreateSecret][google.cloud.secretmanager.v1.SecretManagerService.CreateSecret]. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct CreateSecretRequest { - - /// Required. The resource name of the project to associate with the - /// [Secret][google.cloud.secretmanager.v1.Secret], in the format `projects/*` - /// or `projects/*/locations/*`. - pub parent: String, - - /// Required. This must be unique within the project. - /// - /// A secret ID is a string with a maximum length of 255 characters and can - /// contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and - /// underscore (`_`) characters. - pub secret_id: String, - - /// Required. A [Secret][google.cloud.secretmanager.v1.Secret] with initial - /// field values. - pub secret: Option, -} - -/// Request message for -/// [SecretManagerService.GetSecret][google.cloud.secretmanager.v1.SecretManagerService.GetSecret]. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[non_exhaustive] -pub struct GetSecretRequest { - - /// Required. The resource name of the - /// [Secret][google.cloud.secretmanager.v1.Secret], in the format - /// `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`. - pub name: String, -} diff --git a/generator/cmd/protoc-gen-gclient/testdata/smprotos/resources.proto b/generator/cmd/protoc-gen-gclient/testdata/smprotos/resources.proto deleted file mode 100644 index 7adce715a..000000000 --- a/generator/cmd/protoc-gen-gclient/testdata/smprotos/resources.proto +++ /dev/null @@ -1,490 +0,0 @@ -// 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.cloud.secretmanager.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.Cloud.SecretManager.V1"; -option go_package = "cloud.google.com/go/secretmanager/apiv1/secretmanagerpb;secretmanagerpb"; -option java_multiple_files = true; -option java_outer_classname = "ResourcesProto"; -option java_package = "com.google.cloud.secretmanager.v1"; -option objc_class_prefix = "GSM"; -option php_namespace = "Google\\Cloud\\SecretManager\\V1"; -option ruby_package = "Google::Cloud::SecretManager::V1"; - -// A [Secret][google.cloud.secretmanager.v1.Secret] is a logical secret whose -// value and versions can be accessed. -// -// A [Secret][google.cloud.secretmanager.v1.Secret] is made up of zero or more -// [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] that represent -// the secret data. -message Secret { - option (google.api.resource) = { - type: "secretmanager.googleapis.com/Secret" - pattern: "projects/{project}/secrets/{secret}" - pattern: "projects/{project}/locations/{location}/secrets/{secret}" - plural: "secrets" - singular: "secret" - }; - - // Output only. The resource name of the - // [Secret][google.cloud.secretmanager.v1.Secret] in the format - // `projects/*/secrets/*`. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Immutable. The replication policy of the secret data attached to - // the [Secret][google.cloud.secretmanager.v1.Secret]. - // - // The replication policy cannot be changed after the Secret has been created. - Replication replication = 2 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OPTIONAL - ]; - - // Output only. The time at which the - // [Secret][google.cloud.secretmanager.v1.Secret] was created. - google.protobuf.Timestamp create_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The labels assigned to this Secret. - // - // Label keys must be between 1 and 63 characters long, have a UTF-8 encoding - // of maximum 128 bytes, and must conform to the following PCRE regular - // expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}` - // - // Label values must be between 0 and 63 characters long, have a UTF-8 - // encoding of maximum 128 bytes, and must conform to the following PCRE - // regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}` - // - // No more than 64 labels can be assigned to a given resource. - map labels = 4; - - // Optional. A list of up to 10 Pub/Sub topics to which messages are published - // when control plane operations are called on the secret or its versions. - repeated Topic topics = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Expiration policy attached to the - // [Secret][google.cloud.secretmanager.v1.Secret]. If specified the - // [Secret][google.cloud.secretmanager.v1.Secret] and all - // [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] will be - // automatically deleted at expiration. Expired secrets are irreversibly - // deleted. - // - // Expiration is *not* the recommended way to set time-based permissions. [IAM - // Conditions](https://cloud.google.com/secret-manager/docs/access-control#conditions) - // is recommended for granting time-based permissions because the operation - // can be reversed. - oneof expiration { - // Optional. Timestamp in UTC when the - // [Secret][google.cloud.secretmanager.v1.Secret] is scheduled to expire. - // This is always provided on output, regardless of what was sent on input. - google.protobuf.Timestamp expire_time = 6 - [(google.api.field_behavior) = OPTIONAL]; - - // Input only. The TTL for the - // [Secret][google.cloud.secretmanager.v1.Secret]. - google.protobuf.Duration ttl = 7 [(google.api.field_behavior) = INPUT_ONLY]; - } - - // Optional. Etag of the currently stored - // [Secret][google.cloud.secretmanager.v1.Secret]. - string etag = 8 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Rotation policy attached to the - // [Secret][google.cloud.secretmanager.v1.Secret]. May be excluded if there is - // no rotation policy. - Rotation rotation = 9 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Mapping from version alias to version name. - // - // A version alias is a string with a maximum length of 63 characters and can - // contain uppercase and lowercase letters, numerals, and the hyphen (`-`) - // and underscore ('_') characters. An alias string must start with a - // letter and cannot be the string 'latest' or 'NEW'. - // No more than 50 aliases can be assigned to a given secret. - // - // Version-Alias pairs will be viewable via GetSecret and modifiable via - // UpdateSecret. Access by alias is only be supported on - // GetSecretVersion and AccessSecretVersion. - map version_aliases = 11 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Custom metadata about the secret. - // - // Annotations are distinct from various forms of labels. - // Annotations exist to allow client tools to store their own state - // information without requiring a database. - // - // Annotation keys must be between 1 and 63 characters long, have a UTF-8 - // encoding of maximum 128 bytes, begin and end with an alphanumeric character - // ([a-z0-9A-Z]), and may have dashes (-), underscores (_), dots (.), and - // alphanumerics in between these symbols. - // - // The total size of annotation keys and values must be less than 16KiB. - map annotations = 13 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Secret Version TTL after destruction request - // - // This is a part of the Delayed secret version destroy feature. - // For secret with TTL>0, version destruction doesn't happen immediately - // on calling destroy instead the version goes to a disabled state and - // destruction happens after the TTL expires. - google.protobuf.Duration version_destroy_ttl = 14 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The customer-managed encryption configuration of the Regionalised - // Secrets. If no configuration is provided, Google-managed default encryption - // is used. - // - // Updates to the [Secret][google.cloud.secretmanager.v1.Secret] encryption - // configuration only apply to - // [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] added - // afterwards. They do not apply retroactively to existing - // [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - CustomerManagedEncryption customer_managed_encryption = 15 - [(google.api.field_behavior) = OPTIONAL]; -} - -// A secret version resource in the Secret Manager API. -message SecretVersion { - option (google.api.resource) = { - type: "secretmanager.googleapis.com/SecretVersion" - pattern: "projects/{project}/secrets/{secret}/versions/{secret_version}" - pattern: "projects/{project}/locations/{location}/secrets/{secret}/versions/{secret_version}" - plural: "secretVersions" - singular: "secretVersion" - }; - - // The state of a - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion], indicating if - // it can be accessed. - enum State { - // Not specified. This value is unused and invalid. - STATE_UNSPECIFIED = 0; - - // The [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] may be - // accessed. - ENABLED = 1; - - // The [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] may not - // be accessed, but the secret data is still available and can be placed - // back into the - // [ENABLED][google.cloud.secretmanager.v1.SecretVersion.State.ENABLED] - // state. - DISABLED = 2; - - // The [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] is - // destroyed and the secret data is no longer stored. A version may not - // leave this state once entered. - DESTROYED = 3; - } - - // Output only. The resource name of the - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] in the format - // `projects/*/secrets/*/versions/*`. - // - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] IDs in a - // [Secret][google.cloud.secretmanager.v1.Secret] start at 1 and are - // incremented for each subsequent version of the secret. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time at which the - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] was created. - google.protobuf.Timestamp create_time = 2 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time this - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] was destroyed. - // Only present if [state][google.cloud.secretmanager.v1.SecretVersion.state] - // is - // [DESTROYED][google.cloud.secretmanager.v1.SecretVersion.State.DESTROYED]. - google.protobuf.Timestamp destroy_time = 3 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The current state of the - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The replication status of the - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - ReplicationStatus replication_status = 5; - - // Output only. Etag of the currently stored - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - string etag = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. True if payload checksum specified in - // [SecretPayload][google.cloud.secretmanager.v1.SecretPayload] object has - // been received by - // [SecretManagerService][google.cloud.secretmanager.v1.SecretManagerService] - // on - // [SecretManagerService.AddSecretVersion][google.cloud.secretmanager.v1.SecretManagerService.AddSecretVersion]. - bool client_specified_payload_checksum = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Output only. Scheduled destroy time for secret version. - // This is a part of the Delayed secret version destroy feature. For a - // Secret with a valid version destroy TTL, when a secert version is - // destroyed, the version is moved to disabled state and it is scheduled for - // destruction. The version is destroyed only after the - // `scheduled_destroy_time`. - google.protobuf.Timestamp scheduled_destroy_time = 8 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The customer-managed encryption status of the - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Only - // populated if customer-managed encryption is used and - // [Secret][google.cloud.secretmanager.v1.Secret] is a Regionalised Secret. - CustomerManagedEncryptionStatus customer_managed_encryption = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// A policy that defines the replication and encryption configuration of data. -message Replication { - // A replication policy that replicates the - // [Secret][google.cloud.secretmanager.v1.Secret] payload without any - // restrictions. - message Automatic { - // Optional. The customer-managed encryption configuration of the - // [Secret][google.cloud.secretmanager.v1.Secret]. If no configuration is - // provided, Google-managed default encryption is used. - // - // Updates to the [Secret][google.cloud.secretmanager.v1.Secret] encryption - // configuration only apply to - // [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] added - // afterwards. They do not apply retroactively to existing - // [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - CustomerManagedEncryption customer_managed_encryption = 1 - [(google.api.field_behavior) = OPTIONAL]; - } - - // A replication policy that replicates the - // [Secret][google.cloud.secretmanager.v1.Secret] payload into the locations - // specified in [Secret.replication.user_managed.replicas][] - message UserManaged { - // Represents a Replica for this - // [Secret][google.cloud.secretmanager.v1.Secret]. - message Replica { - // The canonical IDs of the location to replicate data. - // For example: `"us-east1"`. - string location = 1; - - // Optional. The customer-managed encryption configuration of the - // [User-Managed Replica][Replication.UserManaged.Replica]. If no - // configuration is provided, Google-managed default encryption is used. - // - // Updates to the [Secret][google.cloud.secretmanager.v1.Secret] - // encryption configuration only apply to - // [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] added - // afterwards. They do not apply retroactively to existing - // [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - CustomerManagedEncryption customer_managed_encryption = 2 - [(google.api.field_behavior) = OPTIONAL]; - } - - // Required. The list of Replicas for this - // [Secret][google.cloud.secretmanager.v1.Secret]. - // - // Cannot be empty. - repeated Replica replicas = 1 [(google.api.field_behavior) = REQUIRED]; - } - - // The replication policy for this secret. - oneof replication { - // The [Secret][google.cloud.secretmanager.v1.Secret] will automatically be - // replicated without any restrictions. - Automatic automatic = 1; - - // The [Secret][google.cloud.secretmanager.v1.Secret] will only be - // replicated into the locations specified. - UserManaged user_managed = 2; - } -} - -// Configuration for encrypting secret payloads using customer-managed -// encryption keys (CMEK). -message CustomerManagedEncryption { - // Required. The resource name of the Cloud KMS CryptoKey used to encrypt - // secret payloads. - // - // For secrets using the - // [UserManaged][google.cloud.secretmanager.v1.Replication.UserManaged] - // replication policy type, Cloud KMS CryptoKeys must reside in the same - // location as the [replica location][Secret.UserManaged.Replica.location]. - // - // For secrets using the - // [Automatic][google.cloud.secretmanager.v1.Replication.Automatic] - // replication policy type, Cloud KMS CryptoKeys must reside in `global`. - // - // The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`. - string kms_key_name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The replication status of a -// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. -message ReplicationStatus { - // The replication status of a - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] using - // automatic replication. - // - // Only populated if the parent [Secret][google.cloud.secretmanager.v1.Secret] - // has an automatic replication policy. - message AutomaticStatus { - // Output only. The customer-managed encryption status of the - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Only - // populated if customer-managed encryption is used. - CustomerManagedEncryptionStatus customer_managed_encryption = 1 - [(google.api.field_behavior) = OUTPUT_ONLY]; - } - - // The replication status of a - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] using - // user-managed replication. - // - // Only populated if the parent [Secret][google.cloud.secretmanager.v1.Secret] - // has a user-managed replication policy. - message UserManagedStatus { - // Describes the status of a user-managed replica for the - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - message ReplicaStatus { - // Output only. The canonical ID of the replica location. - // For example: `"us-east1"`. - string location = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The customer-managed encryption status of the - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Only - // populated if customer-managed encryption is used. - CustomerManagedEncryptionStatus customer_managed_encryption = 2 - [(google.api.field_behavior) = OUTPUT_ONLY]; - } - - // Output only. The list of replica statuses for the - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - repeated ReplicaStatus replicas = 1 - [(google.api.field_behavior) = OUTPUT_ONLY]; - } - - // The replication status of the - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - oneof replication_status { - // Describes the replication status of a - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] with - // automatic replication. - // - // Only populated if the parent - // [Secret][google.cloud.secretmanager.v1.Secret] has an automatic - // replication policy. - AutomaticStatus automatic = 1; - - // Describes the replication status of a - // [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] with - // user-managed replication. - // - // Only populated if the parent - // [Secret][google.cloud.secretmanager.v1.Secret] has a user-managed - // replication policy. - UserManagedStatus user_managed = 2; - } -} - -// Describes the status of customer-managed encryption. -message CustomerManagedEncryptionStatus { - // Required. The resource name of the Cloud KMS CryptoKeyVersion used to - // encrypt the secret payload, in the following format: - // `projects/*/locations/*/keyRings/*/cryptoKeys/*/versions/*`. - string kms_key_version_name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// A Pub/Sub topic which Secret Manager will publish to when control plane -// events occur on this secret. -message Topic { - option (google.api.resource) = { - type: "pubsub.googleapis.com/Topic" - pattern: "projects/{project}/topics/{topic}" - }; - - // Required. The resource name of the Pub/Sub topic that will be published to, - // in the following format: `projects/*/topics/*`. For publication to succeed, - // the Secret Manager service agent must have the `pubsub.topic.publish` - // permission on the topic. The Pub/Sub Publisher role - // (`roles/pubsub.publisher`) includes this permission. - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The rotation time and period for a -// [Secret][google.cloud.secretmanager.v1.Secret]. At next_rotation_time, Secret -// Manager will send a Pub/Sub notification to the topics configured on the -// Secret. [Secret.topics][google.cloud.secretmanager.v1.Secret.topics] must be -// set to configure rotation. -message Rotation { - // Optional. Timestamp in UTC at which the - // [Secret][google.cloud.secretmanager.v1.Secret] is scheduled to rotate. - // Cannot be set to less than 300s (5 min) in the future and at most - // 3153600000s (100 years). - // - // [next_rotation_time][google.cloud.secretmanager.v1.Rotation.next_rotation_time] - // MUST be set if - // [rotation_period][google.cloud.secretmanager.v1.Rotation.rotation_period] - // is set. - google.protobuf.Timestamp next_rotation_time = 1 - [(google.api.field_behavior) = OPTIONAL]; - - // Input only. The Duration between rotation notifications. Must be in seconds - // and at least 3600s (1h) and at most 3153600000s (100 years). - // - // If - // [rotation_period][google.cloud.secretmanager.v1.Rotation.rotation_period] - // is set, - // [next_rotation_time][google.cloud.secretmanager.v1.Rotation.next_rotation_time] - // must be set. - // [next_rotation_time][google.cloud.secretmanager.v1.Rotation.next_rotation_time] - // will be advanced by this period when the service automatically sends - // rotation notifications. - google.protobuf.Duration rotation_period = 2 - [(google.api.field_behavior) = INPUT_ONLY]; -} - -// A secret payload resource in the Secret Manager API. This contains the -// sensitive secret payload that is associated with a -// [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. -message SecretPayload { - // The secret data. Must be no larger than 64KiB. - bytes data = 1; - - // Optional. If specified, - // [SecretManagerService][google.cloud.secretmanager.v1.SecretManagerService] - // will verify the integrity of the received - // [data][google.cloud.secretmanager.v1.SecretPayload.data] on - // [SecretManagerService.AddSecretVersion][google.cloud.secretmanager.v1.SecretManagerService.AddSecretVersion] - // calls using the crc32c checksum and store it to include in future - // [SecretManagerService.AccessSecretVersion][google.cloud.secretmanager.v1.SecretManagerService.AccessSecretVersion] - // responses. If a checksum is not provided in the - // [SecretManagerService.AddSecretVersion][google.cloud.secretmanager.v1.SecretManagerService.AddSecretVersion] - // request, the - // [SecretManagerService][google.cloud.secretmanager.v1.SecretManagerService] - // will generate and store one for you. - // - // The CRC32C value is encoded as a Int64 for compatibility, and can be - // safely downconverted to uint32 in languages that support this type. - // https://cloud.google.com/apis/design/design_patterns#integer_types - optional int64 data_crc32c = 2 [(google.api.field_behavior) = OPTIONAL]; -} diff --git a/generator/cmd/protoc-gen-gclient/testdata/smprotos/service.proto b/generator/cmd/protoc-gen-gclient/testdata/smprotos/service.proto deleted file mode 100644 index 972ff542d..000000000 --- a/generator/cmd/protoc-gen-gclient/testdata/smprotos/service.proto +++ /dev/null @@ -1,108 +0,0 @@ -// 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.cloud.secretmanager.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "resources.proto"; -import "google/protobuf/field_mask.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.Cloud.SecretManager.V1"; -option go_package = "cloud.google.com/go/secretmanager/apiv1/secretmanagerpb;secretmanagerpb"; -option java_multiple_files = true; -option java_outer_classname = "ServiceProto"; -option java_package = "com.google.cloud.secretmanager.v1"; -option objc_class_prefix = "GSM"; -option php_namespace = "Google\\Cloud\\SecretManager\\V1"; -option ruby_package = "Google::Cloud::SecretManager::V1"; - -// Secret Manager Service -// -// Manages secrets and operations using those secrets. Implements a REST -// model with the following objects: -// -// * [Secret][google.cloud.secretmanager.v1.Secret] -// * [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] -service SecretManagerService { - option (google.api.default_host) = "secretmanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a new [Secret][google.cloud.secretmanager.v1.Secret] containing no - // [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - rpc CreateSecret(CreateSecretRequest) returns (Secret) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/secrets" - body: "secret" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*}/secrets" - body: "secret" - } - }; - option (google.api.method_signature) = "parent,secret_id,secret"; - } - - // Gets metadata for a given [Secret][google.cloud.secretmanager.v1.Secret]. - rpc GetSecret(GetSecretRequest) returns (Secret) { - option (google.api.http) = { - get: "/v1/{name=projects/*/secrets/*}" - additional_bindings { get: "/v1/{name=projects/*/locations/*/secrets/*}" } - }; - option (google.api.method_signature) = "name"; - } -} -// Request message for -// [SecretManagerService.CreateSecret][google.cloud.secretmanager.v1.SecretManagerService.CreateSecret]. -message CreateSecretRequest { - // Required. The resource name of the project to associate with the - // [Secret][google.cloud.secretmanager.v1.Secret], in the format `projects/*` - // or `projects/*/locations/*`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "secretmanager.googleapis.com/Secret" - } - ]; - - // Required. This must be unique within the project. - // - // A secret ID is a string with a maximum length of 255 characters and can - // contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and - // underscore (`_`) characters. - string secret_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. A [Secret][google.cloud.secretmanager.v1.Secret] with initial - // field values. - Secret secret = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for -// [SecretManagerService.GetSecret][google.cloud.secretmanager.v1.SecretManagerService.GetSecret]. -message GetSecretRequest { - // Required. The resource name of the - // [Secret][google.cloud.secretmanager.v1.Secret], in the format - // `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "secretmanager.googleapis.com/Secret" - } - ]; -} diff --git a/generator/devtools/cmd/generate/main.go b/generator/devtools/cmd/generate/main.go index f849ec093..e2f91527c 100644 --- a/generator/devtools/cmd/generate/main.go +++ b/generator/devtools/cmd/generate/main.go @@ -25,10 +25,10 @@ import ( ) var ( - input = flag.String("input", "testdata/google/cloud/secretmanager/v1/", "path to protos to generate from") - output = flag.String("out", "output", "the path to the output directory") - language = flag.String("language", "", "the generated language") - testdata = flag.String("testdata", "testdata/", "path to testdata directory") + output = flag.String("out", "output", "the path to the output directory") + language = flag.String("language", "", "the generated language") + protoFiles = flag.String("files", "testdata/googleapis/google/cloud/secretmanager/v1/", "path to protos to generate from") + protoPath = flag.String("proto_path", "testdata/googleapis", "directory in which to search for imports") ) func main() { @@ -36,7 +36,7 @@ func main() { if *language == "" { log.Fatalf("language must be provided") } - if err := run(*language, *testdata, *input, *output); err != nil { + if err := run(*language, *protoPath, *protoFiles, *output); err != nil { log.Fatal(err) } } diff --git a/generator/testdata/google/api/annotations.proto b/generator/testdata/googleapis/google/api/annotations.proto similarity index 100% rename from generator/testdata/google/api/annotations.proto rename to generator/testdata/googleapis/google/api/annotations.proto diff --git a/generator/testdata/google/api/client.proto b/generator/testdata/googleapis/google/api/client.proto similarity index 100% rename from generator/testdata/google/api/client.proto rename to generator/testdata/googleapis/google/api/client.proto diff --git a/generator/testdata/google/api/field_behavior.proto b/generator/testdata/googleapis/google/api/field_behavior.proto similarity index 100% rename from generator/testdata/google/api/field_behavior.proto rename to generator/testdata/googleapis/google/api/field_behavior.proto diff --git a/generator/testdata/google/api/http.proto b/generator/testdata/googleapis/google/api/http.proto similarity index 100% rename from generator/testdata/google/api/http.proto rename to generator/testdata/googleapis/google/api/http.proto diff --git a/generator/testdata/google/api/launch_stage.proto b/generator/testdata/googleapis/google/api/launch_stage.proto similarity index 100% rename from generator/testdata/google/api/launch_stage.proto rename to generator/testdata/googleapis/google/api/launch_stage.proto diff --git a/generator/testdata/google/api/resource.proto b/generator/testdata/googleapis/google/api/resource.proto similarity index 100% rename from generator/testdata/google/api/resource.proto rename to generator/testdata/googleapis/google/api/resource.proto diff --git a/generator/testdata/google/cloud/secretmanager/v1/resources.proto b/generator/testdata/googleapis/google/cloud/secretmanager/v1/resources.proto similarity index 100% rename from generator/testdata/google/cloud/secretmanager/v1/resources.proto rename to generator/testdata/googleapis/google/cloud/secretmanager/v1/resources.proto diff --git a/generator/testdata/google/cloud/secretmanager/v1/secretmanager_v1.yaml b/generator/testdata/googleapis/google/cloud/secretmanager/v1/secretmanager_v1.yaml similarity index 100% rename from generator/testdata/google/cloud/secretmanager/v1/secretmanager_v1.yaml rename to generator/testdata/googleapis/google/cloud/secretmanager/v1/secretmanager_v1.yaml diff --git a/generator/testdata/google/cloud/secretmanager/v1/service.proto b/generator/testdata/googleapis/google/cloud/secretmanager/v1/service.proto similarity index 100% rename from generator/testdata/google/cloud/secretmanager/v1/service.proto rename to generator/testdata/googleapis/google/cloud/secretmanager/v1/service.proto diff --git a/generator/testdata/google/iam/v1/iam_policy.proto b/generator/testdata/googleapis/google/iam/v1/iam_policy.proto similarity index 100% rename from generator/testdata/google/iam/v1/iam_policy.proto rename to generator/testdata/googleapis/google/iam/v1/iam_policy.proto diff --git a/generator/testdata/google/iam/v1/options.proto b/generator/testdata/googleapis/google/iam/v1/options.proto similarity index 100% rename from generator/testdata/google/iam/v1/options.proto rename to generator/testdata/googleapis/google/iam/v1/options.proto diff --git a/generator/testdata/google/iam/v1/policy.proto b/generator/testdata/googleapis/google/iam/v1/policy.proto similarity index 100% rename from generator/testdata/google/iam/v1/policy.proto rename to generator/testdata/googleapis/google/iam/v1/policy.proto diff --git a/generator/testdata/google/type/expr.proto b/generator/testdata/googleapis/google/type/expr.proto similarity index 100% rename from generator/testdata/google/type/expr.proto rename to generator/testdata/googleapis/google/type/expr.proto diff --git a/generator/cmd/openapi/testdata/secretmanager_openapi_v1.json b/generator/testdata/openapi/secretmanager_openapi_v1.json similarity index 100% rename from generator/cmd/openapi/testdata/secretmanager_openapi_v1.json rename to generator/testdata/openapi/secretmanager_openapi_v1.json diff --git a/generator/cmd/protoc-gen-gclient/testdata/rust/rust.bin b/generator/testdata/rust/gclient/rust.bin similarity index 100% rename from generator/cmd/protoc-gen-gclient/testdata/rust/rust.bin rename to generator/testdata/rust/gclient/rust.bin diff --git a/generator/cmd/openapi/testdata/rust/golden/lib.rs b/generator/testdata/rust/openapi/golden/lib.rs similarity index 100% rename from generator/cmd/openapi/testdata/rust/golden/lib.rs rename to generator/testdata/rust/openapi/golden/lib.rs diff --git a/generator/cmd/openapi/testdata/rust/golden/model.rs b/generator/testdata/rust/openapi/golden/model.rs similarity index 100% rename from generator/cmd/openapi/testdata/rust/golden/model.rs rename to generator/testdata/rust/openapi/golden/model.rs