Skip to content

Commit

Permalink
test(generator/rust): use google.protobuf.Empty in golden files (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
coryan authored Nov 13, 2024
1 parent 7e37818 commit e65d826
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
29 changes: 29 additions & 0 deletions generator/testdata/rust/gclient/golden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,35 @@ impl SecretManagerService {
Ok(response)
}

/// Deletes a [Secret][google.cloud.secretmanager.v1.Secret].
pub async fn delete_secret(
&self,
req: crate::model::DeleteSecretRequest,
) -> Result<gax_placeholder::Empty, Box<dyn std::error::Error>> {
let query_parameters = [gax::query_parameter::format("etag", &req.etag)?];
let client = self.client.inner.clone();
let res = client
.http_client
.delete(format!("{}/v1/{}", self.base_path, req.name,))
.query(&[("alt", "json")])
.query(
&query_parameters
.into_iter()
.flatten()
.collect::<Vec<(&str, String)>>(),
)
.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(),
);
}
let response = res.json::<gax_placeholder::Empty>().await?;
Ok(response)
}

/// Lists [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. This
/// call does not return secret data.
pub async fn list_secret_versions(
Expand Down
11 changes: 11 additions & 0 deletions generator/testdata/rust/gclient/protos/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ service SecretManagerService {
option (google.api.method_signature) = "secret,update_mask";
}

// Deletes a [Secret][google.cloud.secretmanager.v1.Secret].
rpc DeleteSecret(DeleteSecretRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v1/{name=projects/*/secrets/*}"
additional_bindings {
delete: "/v1/{name=projects/*/locations/*/secrets/*}"
}
};
option (google.api.method_signature) = "name";
}

// Lists [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. This
// call does not return secret data.
rpc ListSecretVersions(ListSecretVersionsRequest)
Expand Down

0 comments on commit e65d826

Please sign in to comment.