1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
// This file is @generated by prost-build.
/// Information about the principal, resource, and permission to check.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AccessTuple {
/// Required. The principal whose access you want to check, in the form of
/// the email address that represents that principal. For example,
/// `alice@example.com` or
/// `my-service-account@my-project.iam.gserviceaccount.com`.
///
/// The principal must be a Google Account or a service account. Other types of
/// principals are not supported.
#[prost(string, tag = "1")]
pub principal: ::prost::alloc::string::String,
/// Required. The full resource name that identifies the resource. For example,
/// `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`.
///
/// For examples of full resource names for Google Cloud services, see
/// <https://cloud.google.com/iam/help/troubleshooter/full-resource-names.>
#[prost(string, tag = "2")]
pub full_resource_name: ::prost::alloc::string::String,
/// Required. The IAM permission to check for the specified principal and
/// resource.
///
/// For a complete list of IAM permissions, see
/// <https://cloud.google.com/iam/help/permissions/reference.>
///
/// For a complete list of predefined IAM roles and the permissions in each
/// role, see <https://cloud.google.com/iam/help/roles/reference.>
#[prost(string, tag = "3")]
pub permission: ::prost::alloc::string::String,
}
/// Details about how a specific IAM [Policy][google.iam.v1.Policy] contributed
/// to the access check.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExplainedPolicy {
/// Indicates whether _this policy_ provides the specified permission to the
/// specified principal for the specified resource.
///
/// This field does _not_ indicate whether the principal actually has the
/// permission for the resource. There might be another policy that overrides
/// this policy. To determine whether the principal actually has the
/// permission, use the `access` field in the
/// [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse].
#[prost(enumeration = "AccessState", tag = "1")]
pub access: i32,
/// The full resource name that identifies the resource. For example,
/// `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`.
///
/// If the sender of the request does not have access to the policy, this field
/// is omitted.
///
/// For examples of full resource names for Google Cloud services, see
/// <https://cloud.google.com/iam/help/troubleshooter/full-resource-names.>
#[prost(string, tag = "2")]
pub full_resource_name: ::prost::alloc::string::String,
/// The IAM policy attached to the resource.
///
/// If the sender of the request does not have access to the policy, this field
/// is empty.
#[prost(message, optional, tag = "3")]
pub policy: ::core::option::Option<super::super::super::iam::v1::Policy>,
/// Details about how each binding in the policy affects the principal's
/// ability, or inability, to use the permission for the resource.
///
/// If the sender of the request does not have access to the policy, this field
/// is omitted.
#[prost(message, repeated, tag = "4")]
pub binding_explanations: ::prost::alloc::vec::Vec<BindingExplanation>,
/// The relevance of this policy to the overall determination in the
/// [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse].
///
/// If the sender of the request does not have access to the policy, this field
/// is omitted.
#[prost(enumeration = "HeuristicRelevance", tag = "5")]
pub relevance: i32,
}
/// Details about how a binding in a policy affects a principal's ability to use
/// a permission.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BindingExplanation {
/// Required. Indicates whether _this binding_ provides the specified
/// permission to the specified principal for the specified resource.
///
/// This field does _not_ indicate whether the principal actually has the
/// permission for the resource. There might be another binding that overrides
/// this binding. To determine whether the principal actually has the
/// permission, use the `access` field in the
/// [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse].
#[prost(enumeration = "AccessState", tag = "1")]
pub access: i32,
/// The role that this binding grants. For example,
/// `roles/compute.serviceAgent`.
///
/// For a complete list of predefined IAM roles, as well as the permissions in
/// each role, see <https://cloud.google.com/iam/help/roles/reference.>
#[prost(string, tag = "2")]
pub role: ::prost::alloc::string::String,
/// Indicates whether the role granted by this binding contains the specified
/// permission.
#[prost(enumeration = "binding_explanation::RolePermission", tag = "3")]
pub role_permission: i32,
/// The relevance of the permission's existence, or nonexistence, in the role
/// to the overall determination for the entire policy.
#[prost(enumeration = "HeuristicRelevance", tag = "4")]
pub role_permission_relevance: i32,
/// Indicates whether each principal in the binding includes the principal
/// specified in the request, either directly or indirectly. Each key
/// identifies a principal in the binding, and each value indicates whether the
/// principal in the binding includes the principal in the request.
///
/// For example, suppose that a binding includes the following principals:
///
/// * `user:alice@example.com`
/// * `group:product-eng@example.com`
///
/// You want to troubleshoot access for `user:bob@example.com`. This user is a
/// principal of the group `group:product-eng@example.com`.
///
/// For the first principal in the binding, the key is
/// `user:alice@example.com`, and the `membership` field in the value is set to
/// `MEMBERSHIP_NOT_INCLUDED`.
///
/// For the second principal in the binding, the key is
/// `group:product-eng@example.com`, and the `membership` field in the value is
/// set to `MEMBERSHIP_INCLUDED`.
#[prost(btree_map = "string, message", tag = "5")]
pub memberships: ::prost::alloc::collections::BTreeMap<
::prost::alloc::string::String,
binding_explanation::AnnotatedMembership,
>,
/// The relevance of this binding to the overall determination for the entire
/// policy.
#[prost(enumeration = "HeuristicRelevance", tag = "6")]
pub relevance: i32,
/// A condition expression that prevents this binding from granting access
/// unless the expression evaluates to `true`.
///
/// To learn about IAM Conditions, see
/// <https://cloud.google.com/iam/help/conditions/overview.>
#[prost(message, optional, tag = "7")]
pub condition: ::core::option::Option<super::super::super::r#type::Expr>,
}
/// Nested message and enum types in `BindingExplanation`.
pub mod binding_explanation {
/// Details about whether the binding includes the principal.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct AnnotatedMembership {
/// Indicates whether the binding includes the principal.
#[prost(enumeration = "Membership", tag = "1")]
pub membership: i32,
/// The relevance of the principal's status to the overall determination for
/// the binding.
#[prost(enumeration = "super::HeuristicRelevance", tag = "2")]
pub relevance: i32,
}
/// Whether a role includes a specific permission.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum RolePermission {
/// Default value. This value is unused.
Unspecified = 0,
/// The permission is included in the role.
Included = 1,
/// The permission is not included in the role.
NotIncluded = 2,
/// The sender of the request is not allowed to access the binding.
UnknownInfoDenied = 3,
}
impl RolePermission {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
RolePermission::Unspecified => "ROLE_PERMISSION_UNSPECIFIED",
RolePermission::Included => "ROLE_PERMISSION_INCLUDED",
RolePermission::NotIncluded => "ROLE_PERMISSION_NOT_INCLUDED",
RolePermission::UnknownInfoDenied => {
"ROLE_PERMISSION_UNKNOWN_INFO_DENIED"
}
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ROLE_PERMISSION_UNSPECIFIED" => Some(Self::Unspecified),
"ROLE_PERMISSION_INCLUDED" => Some(Self::Included),
"ROLE_PERMISSION_NOT_INCLUDED" => Some(Self::NotIncluded),
"ROLE_PERMISSION_UNKNOWN_INFO_DENIED" => Some(Self::UnknownInfoDenied),
_ => None,
}
}
}
/// Whether the binding includes the principal.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Membership {
/// Default value. This value is unused.
Unspecified = 0,
/// The binding includes the principal. The principal can be included
/// directly or indirectly. For example:
///
/// * A principal is included directly if that principal is listed in the
/// binding.
/// * A principal is included indirectly if that principal is in a Google
/// group or Google Workspace domain that is listed in the binding.
Included = 1,
/// The binding does not include the principal.
NotIncluded = 2,
/// The sender of the request is not allowed to access the binding.
UnknownInfoDenied = 3,
/// The principal is an unsupported type. Only Google Accounts and service
/// accounts are supported.
UnknownUnsupported = 4,
}
impl Membership {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Membership::Unspecified => "MEMBERSHIP_UNSPECIFIED",
Membership::Included => "MEMBERSHIP_INCLUDED",
Membership::NotIncluded => "MEMBERSHIP_NOT_INCLUDED",
Membership::UnknownInfoDenied => "MEMBERSHIP_UNKNOWN_INFO_DENIED",
Membership::UnknownUnsupported => "MEMBERSHIP_UNKNOWN_UNSUPPORTED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"MEMBERSHIP_UNSPECIFIED" => Some(Self::Unspecified),
"MEMBERSHIP_INCLUDED" => Some(Self::Included),
"MEMBERSHIP_NOT_INCLUDED" => Some(Self::NotIncluded),
"MEMBERSHIP_UNKNOWN_INFO_DENIED" => Some(Self::UnknownInfoDenied),
"MEMBERSHIP_UNKNOWN_UNSUPPORTED" => Some(Self::UnknownUnsupported),
_ => None,
}
}
}
}
/// Whether a principal has a permission for a resource.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum AccessState {
/// Default value. This value is unused.
Unspecified = 0,
/// The principal has the permission.
Granted = 1,
/// The principal does not have the permission.
NotGranted = 2,
/// The principal has the permission only if a condition expression evaluates
/// to `true`.
UnknownConditional = 3,
/// The sender of the request does not have access to all of the policies that
/// Policy Troubleshooter needs to evaluate.
UnknownInfoDenied = 4,
}
impl AccessState {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
AccessState::Unspecified => "ACCESS_STATE_UNSPECIFIED",
AccessState::Granted => "GRANTED",
AccessState::NotGranted => "NOT_GRANTED",
AccessState::UnknownConditional => "UNKNOWN_CONDITIONAL",
AccessState::UnknownInfoDenied => "UNKNOWN_INFO_DENIED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ACCESS_STATE_UNSPECIFIED" => Some(Self::Unspecified),
"GRANTED" => Some(Self::Granted),
"NOT_GRANTED" => Some(Self::NotGranted),
"UNKNOWN_CONDITIONAL" => Some(Self::UnknownConditional),
"UNKNOWN_INFO_DENIED" => Some(Self::UnknownInfoDenied),
_ => None,
}
}
}
/// The extent to which a single data point, such as the existence of a binding
/// or whether a binding includes a specific principal, contributes to an overall
/// determination.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum HeuristicRelevance {
/// Default value. This value is unused.
Unspecified = 0,
/// The data point has a limited effect on the result. Changing the data point
/// is unlikely to affect the overall determination.
Normal = 1,
/// The data point has a strong effect on the result. Changing the data point
/// is likely to affect the overall determination.
High = 2,
}
impl HeuristicRelevance {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
HeuristicRelevance::Unspecified => "HEURISTIC_RELEVANCE_UNSPECIFIED",
HeuristicRelevance::Normal => "NORMAL",
HeuristicRelevance::High => "HIGH",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"HEURISTIC_RELEVANCE_UNSPECIFIED" => Some(Self::Unspecified),
"NORMAL" => Some(Self::Normal),
"HIGH" => Some(Self::High),
_ => None,
}
}
}
/// Request for
/// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy].
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TroubleshootIamPolicyRequest {
/// The information to use for checking whether a principal has a permission
/// for a resource.
#[prost(message, optional, tag = "1")]
pub access_tuple: ::core::option::Option<AccessTuple>,
}
/// Response for
/// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy].
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TroubleshootIamPolicyResponse {
/// Indicates whether the principal has the specified permission for the
/// specified resource, based on evaluating all of the applicable IAM policies.
#[prost(enumeration = "AccessState", tag = "1")]
pub access: i32,
/// List of IAM policies that were evaluated to check the principal's
/// permissions, with annotations to indicate how each policy contributed to
/// the final result.
///
/// The list of policies can include the policy for the resource itself. It can
/// also include policies that are inherited from higher levels of the resource
/// hierarchy, including the organization, the folder, and the project.
///
/// To learn more about the resource hierarchy, see
/// <https://cloud.google.com/iam/help/resource-hierarchy.>
#[prost(message, repeated, tag = "2")]
pub explained_policies: ::prost::alloc::vec::Vec<ExplainedPolicy>,
/// The general errors contained in the troubleshooting response.
#[prost(message, repeated, tag = "3")]
pub errors: ::prost::alloc::vec::Vec<super::super::super::rpc::Status>,
}
/// Generated client implementations.
pub mod iam_checker_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// IAM Policy Troubleshooter service.
///
/// This service helps you troubleshoot access issues for Google Cloud resources.
#[derive(Debug, Clone)]
pub struct IamCheckerClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> IamCheckerClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> IamCheckerClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
IamCheckerClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Checks whether a principal has a specific permission for a specific
/// resource, and explains why the principal does or does not have that
/// permission.
pub async fn troubleshoot_iam_policy(
&mut self,
request: impl tonic::IntoRequest<super::TroubleshootIamPolicyRequest>,
) -> std::result::Result<
tonic::Response<super::TroubleshootIamPolicyResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.cloud.policytroubleshooter.v1.IamChecker/TroubleshootIamPolicy",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.cloud.policytroubleshooter.v1.IamChecker",
"TroubleshootIamPolicy",
),
);
self.inner.unary(req, path, codec).await
}
}
}