use crate::Result;
#[derive(Clone, Debug)]
pub struct CloudShellService<T>
where
T: super::stub::CloudShellService + std::fmt::Debug + Send + Sync,
{
inner: T,
duration: gaxi::observability::DurationMetric,
}
impl<T> CloudShellService<T>
where
T: super::stub::CloudShellService + std::fmt::Debug + Send + Sync,
{
pub fn new(inner: T) -> Self {
Self {
inner,
duration: gaxi::observability::DurationMetric::new(&info::INSTRUMENTATION_CLIENT_INFO),
}
}
}
impl<T> super::stub::CloudShellService for CloudShellService<T>
where
T: super::stub::CloudShellService + std::fmt::Debug + Send + Sync,
{
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn get_environment(
&self,
req: crate::model::GetEnvironmentRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<crate::model::Environment>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::CloudShellService::get_environment",
self.inner.get_environment(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn start_environment(
&self,
req: crate::model::StartEnvironmentRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<google_cloud_longrunning::model::Operation>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::CloudShellService::start_environment",
self.inner.start_environment(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn authorize_environment(
&self,
req: crate::model::AuthorizeEnvironmentRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<google_cloud_longrunning::model::Operation>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::CloudShellService::authorize_environment",
self.inner.authorize_environment(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn add_public_key(
&self,
req: crate::model::AddPublicKeyRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<google_cloud_longrunning::model::Operation>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::CloudShellService::add_public_key",
self.inner.add_public_key(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn remove_public_key(
&self,
req: crate::model::RemovePublicKeyRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<google_cloud_longrunning::model::Operation>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::CloudShellService::remove_public_key",
self.inner.remove_public_key(req, options));
pending.await
}
#[tracing::instrument(level = tracing::Level::DEBUG, ret)]
async fn get_operation(
&self,
req: google_cloud_longrunning::model::GetOperationRequest,
options: crate::RequestOptions,
) -> Result<crate::Response<google_cloud_longrunning::model::Operation>> {
let (_span, pending) = gaxi::client_request_signals!(
metric: self.duration.clone(),
info: *info::INSTRUMENTATION_CLIENT_INFO,
method: "client::CloudShellService::get_operation",
self.inner.get_operation(req, options));
pending.await
}
fn get_polling_error_policy(
&self,
options: &crate::RequestOptions,
) -> std::sync::Arc<dyn google_cloud_gax::polling_error_policy::PollingErrorPolicy> {
self.inner.get_polling_error_policy(options)
}
fn get_polling_backoff_policy(
&self,
options: &crate::RequestOptions,
) -> std::sync::Arc<dyn google_cloud_gax::polling_backoff_policy::PollingBackoffPolicy> {
self.inner.get_polling_backoff_policy(options)
}
}
pub(crate) mod info {
const NAME: &str = env!("CARGO_PKG_NAME");
const VERSION: &str = env!("CARGO_PKG_VERSION");
pub(crate) static INSTRUMENTATION_CLIENT_INFO: std::sync::LazyLock<
gaxi::options::InstrumentationClientInfo,
> = std::sync::LazyLock::new(|| {
let mut info = gaxi::options::InstrumentationClientInfo::default();
info.service_name = "cloudshell";
info.client_version = VERSION;
info.client_artifact = NAME;
info.default_host = "cloudshell";
info
});
}