1 // Copyright 2024 Google LLC. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated file. DO NOT EDIT. 6 7 // Package policytroubleshooter provides access to the Policy Troubleshooter API. 8 // 9 // For product documentation, see: https://cloud.google.com/iam/ 10 // 11 // # Library status 12 // 13 // These client libraries are officially supported by Google. However, this 14 // library is considered complete and is in maintenance mode. This means 15 // that we will address critical bugs and security issues but will not add 16 // any new features. 17 // 18 // When possible, we recommend using our newer 19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) 20 // that are still actively being worked and iterated on. 21 // 22 // # Creating a client 23 // 24 // Usage example: 25 // 26 // import "google.golang.org/api/policytroubleshooter/v1beta" 27 // ... 28 // ctx := context.Background() 29 // policytroubleshooterService, err := policytroubleshooter.NewService(ctx) 30 // 31 // In this example, Google Application Default Credentials are used for 32 // authentication. For information on how to create and obtain Application 33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 34 // 35 // # Other authentication options 36 // 37 // To use an API key for authentication (note: some APIs do not support API 38 // keys), use [google.golang.org/api/option.WithAPIKey]: 39 // 40 // policytroubleshooterService, err := policytroubleshooter.NewService(ctx, option.WithAPIKey("AIza...")) 41 // 42 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth 43 // flow, use [google.golang.org/api/option.WithTokenSource]: 44 // 45 // config := &oauth2.Config{...} 46 // // ... 47 // token, err := config.Exchange(ctx, ...) 48 // policytroubleshooterService, err := policytroubleshooter.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 49 // 50 // See [google.golang.org/api/option.ClientOption] for details on options. 51 package policytroubleshooter // import "google.golang.org/api/policytroubleshooter/v1beta" 52 53 import ( 54 "bytes" 55 "context" 56 "encoding/json" 57 "errors" 58 "fmt" 59 "io" 60 "net/http" 61 "net/url" 62 "strconv" 63 "strings" 64 65 googleapi "google.golang.org/api/googleapi" 66 internal "google.golang.org/api/internal" 67 gensupport "google.golang.org/api/internal/gensupport" 68 option "google.golang.org/api/option" 69 internaloption "google.golang.org/api/option/internaloption" 70 htransport "google.golang.org/api/transport/http" 71 ) 72 73 // Always reference these packages, just in case the auto-generated code 74 // below doesn't. 75 var _ = bytes.NewBuffer 76 var _ = strconv.Itoa 77 var _ = fmt.Sprintf 78 var _ = json.NewDecoder 79 var _ = io.Copy 80 var _ = url.Parse 81 var _ = gensupport.MarshalJSON 82 var _ = googleapi.Version 83 var _ = errors.New 84 var _ = strings.Replace 85 var _ = context.Canceled 86 var _ = internaloption.WithDefaultEndpoint 87 var _ = internal.Version 88 89 const apiId = "policytroubleshooter:v1beta" 90 const apiName = "policytroubleshooter" 91 const apiVersion = "v1beta" 92 const basePath = "https://policytroubleshooter.googleapis.com/" 93 const basePathTemplate = "https://policytroubleshooter.UNIVERSE_DOMAIN/" 94 const mtlsBasePath = "https://policytroubleshooter.mtls.googleapis.com/" 95 96 // OAuth2 scopes used by this API. 97 const ( 98 // See, edit, configure, and delete your Google Cloud data and see the email 99 // address for your Google Account. 100 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" 101 ) 102 103 // NewService creates a new Service. 104 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 105 scopesOption := internaloption.WithDefaultScopes( 106 "https://www.googleapis.com/auth/cloud-platform", 107 ) 108 // NOTE: prepend, so we don't override user-specified scopes. 109 opts = append([]option.ClientOption{scopesOption}, opts...) 110 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 111 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) 112 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 113 opts = append(opts, internaloption.EnableNewAuthLibrary()) 114 client, endpoint, err := htransport.NewClient(ctx, opts...) 115 if err != nil { 116 return nil, err 117 } 118 s, err := New(client) 119 if err != nil { 120 return nil, err 121 } 122 if endpoint != "" { 123 s.BasePath = endpoint 124 } 125 return s, nil 126 } 127 128 // New creates a new Service. It uses the provided http.Client for requests. 129 // 130 // Deprecated: please use NewService instead. 131 // To provide a custom HTTP client, use option.WithHTTPClient. 132 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 133 func New(client *http.Client) (*Service, error) { 134 if client == nil { 135 return nil, errors.New("client is nil") 136 } 137 s := &Service{client: client, BasePath: basePath} 138 s.Iam = NewIamService(s) 139 return s, nil 140 } 141 142 type Service struct { 143 client *http.Client 144 BasePath string // API endpoint base URL 145 UserAgent string // optional additional User-Agent fragment 146 147 Iam *IamService 148 } 149 150 func (s *Service) userAgent() string { 151 if s.UserAgent == "" { 152 return googleapi.UserAgent 153 } 154 return googleapi.UserAgent + " " + s.UserAgent 155 } 156 157 func NewIamService(s *Service) *IamService { 158 rs := &IamService{s: s} 159 return rs 160 } 161 162 type IamService struct { 163 s *Service 164 } 165 166 // GoogleCloudPolicytroubleshooterV1betaAccessTuple: Information about the 167 // member, resource, and permission to check. 168 type GoogleCloudPolicytroubleshooterV1betaAccessTuple struct { 169 // FullResourceName: Required. The full resource name that identifies the 170 // resource. For example, 171 // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/m 172 // y-instance`. For examples of full resource names for Google Cloud services, 173 // see https://cloud.google.com/iam/help/troubleshooter/full-resource-names. 174 FullResourceName string `json:"fullResourceName,omitempty"` 175 // Permission: Required. The IAM permission to check for the specified member 176 // and resource. For a complete list of IAM permissions, see 177 // https://cloud.google.com/iam/help/permissions/reference. For a complete list 178 // of predefined IAM roles and the permissions in each role, see 179 // https://cloud.google.com/iam/help/roles/reference. 180 Permission string `json:"permission,omitempty"` 181 // Principal: Required. The member, or principal, whose access you want to 182 // check, in the form of the email address that represents that member. For 183 // example, `alice@example.com` or 184 // `my-service-account@my-project.iam.gserviceaccount.com`. The member must be 185 // a Google Account or a service account. Other types of members are not 186 // supported. 187 Principal string `json:"principal,omitempty"` 188 // ForceSendFields is a list of field names (e.g. "FullResourceName") to 189 // unconditionally include in API requests. By default, fields with empty or 190 // default values are omitted from API requests. See 191 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 192 // details. 193 ForceSendFields []string `json:"-"` 194 // NullFields is a list of field names (e.g. "FullResourceName") to include in 195 // API requests with the JSON null value. By default, fields with empty values 196 // are omitted from API requests. See 197 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 198 NullFields []string `json:"-"` 199 } 200 201 func (s *GoogleCloudPolicytroubleshooterV1betaAccessTuple) MarshalJSON() ([]byte, error) { 202 type NoMethod GoogleCloudPolicytroubleshooterV1betaAccessTuple 203 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 204 } 205 206 // GoogleCloudPolicytroubleshooterV1betaBindingExplanation: Details about how a 207 // binding in a policy affects a member's ability to use a permission. 208 type GoogleCloudPolicytroubleshooterV1betaBindingExplanation struct { 209 // Access: Indicates whether _this binding_ provides the specified permission 210 // to the specified member for the specified resource. This field does _not_ 211 // indicate whether the member actually has the permission for the resource. 212 // There might be another binding that overrides this binding. To determine 213 // whether the member actually has the permission, use the `access` field in 214 // the TroubleshootIamPolicyResponse. 215 // 216 // Possible values: 217 // "ACCESS_STATE_UNSPECIFIED" - Reserved for future use. 218 // "GRANTED" - The member has the permission. 219 // "NOT_GRANTED" - The member does not have the permission. 220 // "UNKNOWN_CONDITIONAL" - The member has the permission only if a condition 221 // expression evaluates to `true`. 222 // "UNKNOWN_INFO_DENIED" - The sender of the request does not have access to 223 // all of the policies that Policy Troubleshooter needs to evaluate. 224 Access string `json:"access,omitempty"` 225 // Condition: A condition expression that prevents access unless the expression 226 // evaluates to `true`. To learn about IAM Conditions, see 227 // https://cloud.google.com/iam/help/conditions/overview. 228 Condition *GoogleTypeExpr `json:"condition,omitempty"` 229 // Memberships: Indicates whether each member in the binding includes the 230 // member specified in the request, either directly or indirectly. Each key 231 // identifies a member in the binding, and each value indicates whether the 232 // member in the binding includes the member in the request. For example, 233 // suppose that a binding includes the following members: * 234 // `user:alice@example.com` * `group:product-eng@example.com` You want to 235 // troubleshoot access for `user:bob@example.com`. This user is a member of the 236 // group `group:product-eng@example.com`. For the first member in the binding, 237 // the key is `user:alice@example.com`, and the `membership` field in the value 238 // is set to `MEMBERSHIP_NOT_INCLUDED`. For the second member in the binding, 239 // the key is `group:product-eng@example.com`, and the `membership` field in 240 // the value is set to `MEMBERSHIP_INCLUDED`. 241 Memberships map[string]GoogleCloudPolicytroubleshooterV1betaBindingExplanationAnnotatedMembership `json:"memberships,omitempty"` 242 // Relevance: The relevance of this binding to the overall determination for 243 // the entire policy. 244 // 245 // Possible values: 246 // "HEURISTIC_RELEVANCE_UNSPECIFIED" - Reserved for future use. 247 // "NORMAL" - The data point has a limited effect on the result. Changing the 248 // data point is unlikely to affect the overall determination. 249 // "HIGH" - The data point has a strong effect on the result. Changing the 250 // data point is likely to affect the overall determination. 251 Relevance string `json:"relevance,omitempty"` 252 // Role: The role that this binding grants. For example, 253 // `roles/compute.serviceAgent`. For a complete list of predefined IAM roles, 254 // as well as the permissions in each role, see 255 // https://cloud.google.com/iam/help/roles/reference. 256 Role string `json:"role,omitempty"` 257 // RolePermission: Indicates whether the role granted by this binding contains 258 // the specified permission. 259 // 260 // Possible values: 261 // "ROLE_PERMISSION_UNSPECIFIED" - Reserved for future use. 262 // "ROLE_PERMISSION_INCLUDED" - The permission is included in the role. 263 // "ROLE_PERMISSION_NOT_INCLUDED" - The permission is not included in the 264 // role. 265 // "ROLE_PERMISSION_UNKNOWN_INFO_DENIED" - The sender of the request is not 266 // allowed to access the binding. 267 RolePermission string `json:"rolePermission,omitempty"` 268 // RolePermissionRelevance: The relevance of the permission's existence, or 269 // nonexistence, in the role to the overall determination for the entire 270 // policy. 271 // 272 // Possible values: 273 // "HEURISTIC_RELEVANCE_UNSPECIFIED" - Reserved for future use. 274 // "NORMAL" - The data point has a limited effect on the result. Changing the 275 // data point is unlikely to affect the overall determination. 276 // "HIGH" - The data point has a strong effect on the result. Changing the 277 // data point is likely to affect the overall determination. 278 RolePermissionRelevance string `json:"rolePermissionRelevance,omitempty"` 279 // ForceSendFields is a list of field names (e.g. "Access") to unconditionally 280 // include in API requests. By default, fields with empty or default values are 281 // omitted from API requests. See 282 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 283 // details. 284 ForceSendFields []string `json:"-"` 285 // NullFields is a list of field names (e.g. "Access") to include in API 286 // requests with the JSON null value. By default, fields with empty values are 287 // omitted from API requests. See 288 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 289 NullFields []string `json:"-"` 290 } 291 292 func (s *GoogleCloudPolicytroubleshooterV1betaBindingExplanation) MarshalJSON() ([]byte, error) { 293 type NoMethod GoogleCloudPolicytroubleshooterV1betaBindingExplanation 294 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 295 } 296 297 // GoogleCloudPolicytroubleshooterV1betaBindingExplanationAnnotatedMembership: 298 // Details about whether the binding includes the member. 299 type GoogleCloudPolicytroubleshooterV1betaBindingExplanationAnnotatedMembership struct { 300 // Membership: Indicates whether the binding includes the member. 301 // 302 // Possible values: 303 // "MEMBERSHIP_UNSPECIFIED" - Reserved for future use. 304 // "MEMBERSHIP_INCLUDED" - The binding includes the member. The member can be 305 // included directly or indirectly. For example: * A member is included 306 // directly if that member is listed in the binding. * A member is included 307 // indirectly if that member is in a Google group or G Suite domain that is 308 // listed in the binding. 309 // "MEMBERSHIP_NOT_INCLUDED" - The binding does not include the member. 310 // "MEMBERSHIP_UNKNOWN_INFO_DENIED" - The sender of the request is not 311 // allowed to access the binding. 312 // "MEMBERSHIP_UNKNOWN_UNSUPPORTED" - The member is an unsupported type. Only 313 // Google Accounts and service accounts are supported. 314 Membership string `json:"membership,omitempty"` 315 // Relevance: The relevance of the member's status to the overall determination 316 // for the binding. 317 // 318 // Possible values: 319 // "HEURISTIC_RELEVANCE_UNSPECIFIED" - Reserved for future use. 320 // "NORMAL" - The data point has a limited effect on the result. Changing the 321 // data point is unlikely to affect the overall determination. 322 // "HIGH" - The data point has a strong effect on the result. Changing the 323 // data point is likely to affect the overall determination. 324 Relevance string `json:"relevance,omitempty"` 325 // ForceSendFields is a list of field names (e.g. "Membership") to 326 // unconditionally include in API requests. By default, fields with empty or 327 // default values are omitted from API requests. See 328 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 329 // details. 330 ForceSendFields []string `json:"-"` 331 // NullFields is a list of field names (e.g. "Membership") to include in API 332 // requests with the JSON null value. By default, fields with empty values are 333 // omitted from API requests. See 334 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 335 NullFields []string `json:"-"` 336 } 337 338 func (s *GoogleCloudPolicytroubleshooterV1betaBindingExplanationAnnotatedMembership) MarshalJSON() ([]byte, error) { 339 type NoMethod GoogleCloudPolicytroubleshooterV1betaBindingExplanationAnnotatedMembership 340 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 341 } 342 343 // GoogleCloudPolicytroubleshooterV1betaExplainedPolicy: Details about how a 344 // specific IAM Policy contributed to the access check. 345 type GoogleCloudPolicytroubleshooterV1betaExplainedPolicy struct { 346 // Access: Indicates whether _this policy_ provides the specified permission to 347 // the specified member for the specified resource. This field does _not_ 348 // indicate whether the member actually has the permission for the resource. 349 // There might be another policy that overrides this policy. To determine 350 // whether the member actually has the permission, use the `access` field in 351 // the TroubleshootIamPolicyResponse. 352 // 353 // Possible values: 354 // "ACCESS_STATE_UNSPECIFIED" - Reserved for future use. 355 // "GRANTED" - The member has the permission. 356 // "NOT_GRANTED" - The member does not have the permission. 357 // "UNKNOWN_CONDITIONAL" - The member has the permission only if a condition 358 // expression evaluates to `true`. 359 // "UNKNOWN_INFO_DENIED" - The sender of the request does not have access to 360 // all of the policies that Policy Troubleshooter needs to evaluate. 361 Access string `json:"access,omitempty"` 362 // BindingExplanations: Details about how each binding in the policy affects 363 // the member's ability, or inability, to use the permission for the resource. 364 // If the sender of the request does not have access to the policy, this field 365 // is omitted. 366 BindingExplanations []*GoogleCloudPolicytroubleshooterV1betaBindingExplanation `json:"bindingExplanations,omitempty"` 367 // FullResourceName: The full resource name that identifies the resource. For 368 // example, 369 // `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/m 370 // y-instance`. If the sender of the request does not have access to the 371 // policy, this field is omitted. For examples of full resource names for 372 // Google Cloud services, see 373 // https://cloud.google.com/iam/help/troubleshooter/full-resource-names. 374 FullResourceName string `json:"fullResourceName,omitempty"` 375 // Policy: The IAM policy attached to the resource. If the sender of the 376 // request does not have access to the policy, this field is empty. 377 Policy *GoogleIamV1Policy `json:"policy,omitempty"` 378 // Relevance: The relevance of this policy to the overall determination in the 379 // TroubleshootIamPolicyResponse. If the sender of the request does not have 380 // access to the policy, this field is omitted. 381 // 382 // Possible values: 383 // "HEURISTIC_RELEVANCE_UNSPECIFIED" - Reserved for future use. 384 // "NORMAL" - The data point has a limited effect on the result. Changing the 385 // data point is unlikely to affect the overall determination. 386 // "HIGH" - The data point has a strong effect on the result. Changing the 387 // data point is likely to affect the overall determination. 388 Relevance string `json:"relevance,omitempty"` 389 // ForceSendFields is a list of field names (e.g. "Access") to unconditionally 390 // include in API requests. By default, fields with empty or default values are 391 // omitted from API requests. See 392 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 393 // details. 394 ForceSendFields []string `json:"-"` 395 // NullFields is a list of field names (e.g. "Access") to include in API 396 // requests with the JSON null value. By default, fields with empty values are 397 // omitted from API requests. See 398 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 399 NullFields []string `json:"-"` 400 } 401 402 func (s *GoogleCloudPolicytroubleshooterV1betaExplainedPolicy) MarshalJSON() ([]byte, error) { 403 type NoMethod GoogleCloudPolicytroubleshooterV1betaExplainedPolicy 404 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 405 } 406 407 // GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyRequest: Request 408 // for TroubleshootIamPolicy. 409 type GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyRequest struct { 410 // AccessTuple: The information to use for checking whether a member has a 411 // permission for a resource. 412 AccessTuple *GoogleCloudPolicytroubleshooterV1betaAccessTuple `json:"accessTuple,omitempty"` 413 // ForceSendFields is a list of field names (e.g. "AccessTuple") to 414 // unconditionally include in API requests. By default, fields with empty or 415 // default values are omitted from API requests. See 416 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 417 // details. 418 ForceSendFields []string `json:"-"` 419 // NullFields is a list of field names (e.g. "AccessTuple") to include in API 420 // requests with the JSON null value. By default, fields with empty values are 421 // omitted from API requests. See 422 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 423 NullFields []string `json:"-"` 424 } 425 426 func (s *GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyRequest) MarshalJSON() ([]byte, error) { 427 type NoMethod GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyRequest 428 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 429 } 430 431 // GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyResponse: Response 432 // for TroubleshootIamPolicy. 433 type GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyResponse struct { 434 // Access: Indicates whether the member has the specified permission for the 435 // specified resource, based on evaluating all of the applicable policies. 436 // 437 // Possible values: 438 // "ACCESS_STATE_UNSPECIFIED" - Reserved for future use. 439 // "GRANTED" - The member has the permission. 440 // "NOT_GRANTED" - The member does not have the permission. 441 // "UNKNOWN_CONDITIONAL" - The member has the permission only if a condition 442 // expression evaluates to `true`. 443 // "UNKNOWN_INFO_DENIED" - The sender of the request does not have access to 444 // all of the policies that Policy Troubleshooter needs to evaluate. 445 Access string `json:"access,omitempty"` 446 // ExplainedPolicies: List of IAM policies that were evaluated to check the 447 // member's permissions, with annotations to indicate how each policy 448 // contributed to the final result. The list of policies can include the policy 449 // for the resource itself. It can also include policies that are inherited 450 // from higher levels of the resource hierarchy, including the organization, 451 // the folder, and the project. To learn more about the resource hierarchy, see 452 // https://cloud.google.com/iam/help/resource-hierarchy. 453 ExplainedPolicies []*GoogleCloudPolicytroubleshooterV1betaExplainedPolicy `json:"explainedPolicies,omitempty"` 454 455 // ServerResponse contains the HTTP response code and headers from the server. 456 googleapi.ServerResponse `json:"-"` 457 // ForceSendFields is a list of field names (e.g. "Access") to unconditionally 458 // include in API requests. By default, fields with empty or default values are 459 // omitted from API requests. See 460 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 461 // details. 462 ForceSendFields []string `json:"-"` 463 // NullFields is a list of field names (e.g. "Access") to include in API 464 // requests with the JSON null value. By default, fields with empty values are 465 // omitted from API requests. See 466 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 467 NullFields []string `json:"-"` 468 } 469 470 func (s *GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyResponse) MarshalJSON() ([]byte, error) { 471 type NoMethod GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyResponse 472 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 473 } 474 475 // GoogleIamV1AuditConfig: Specifies the audit configuration for a service. The 476 // configuration determines which permission types are logged, and what 477 // identities, if any, are exempted from logging. An AuditConfig must have one 478 // or more AuditLogConfigs. If there are AuditConfigs for both `allServices` 479 // and a specific service, the union of the two AuditConfigs is used for that 480 // service: the log_types specified in each AuditConfig are enabled, and the 481 // exempted_members in each AuditLogConfig are exempted. Example Policy with 482 // multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", 483 // "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ 484 // "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": 485 // "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", 486 // "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": 487 // "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For 488 // sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ 489 // logging. It also exempts `jose@example.com` from DATA_READ logging, and 490 // `aliya@example.com` from DATA_WRITE logging. 491 type GoogleIamV1AuditConfig struct { 492 // AuditLogConfigs: The configuration for logging of each type of permission. 493 AuditLogConfigs []*GoogleIamV1AuditLogConfig `json:"auditLogConfigs,omitempty"` 494 // Service: Specifies a service that will be enabled for audit logging. For 495 // example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` 496 // is a special value that covers all services. 497 Service string `json:"service,omitempty"` 498 // ForceSendFields is a list of field names (e.g. "AuditLogConfigs") to 499 // unconditionally include in API requests. By default, fields with empty or 500 // default values are omitted from API requests. See 501 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 502 // details. 503 ForceSendFields []string `json:"-"` 504 // NullFields is a list of field names (e.g. "AuditLogConfigs") to include in 505 // API requests with the JSON null value. By default, fields with empty values 506 // are omitted from API requests. See 507 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 508 NullFields []string `json:"-"` 509 } 510 511 func (s *GoogleIamV1AuditConfig) MarshalJSON() ([]byte, error) { 512 type NoMethod GoogleIamV1AuditConfig 513 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 514 } 515 516 // GoogleIamV1AuditLogConfig: Provides the configuration for logging a type of 517 // permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", 518 // "exempted_members": [ "user:jose@example.com" ] }, { "log_type": 519 // "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while 520 // exempting jose@example.com from DATA_READ logging. 521 type GoogleIamV1AuditLogConfig struct { 522 // ExemptedMembers: Specifies the identities that do not cause logging for this 523 // type of permission. Follows the same format of Binding.members. 524 ExemptedMembers []string `json:"exemptedMembers,omitempty"` 525 // LogType: The log type that this config enables. 526 // 527 // Possible values: 528 // "LOG_TYPE_UNSPECIFIED" - Default case. Should never be this. 529 // "ADMIN_READ" - Admin reads. Example: CloudIAM getIamPolicy 530 // "DATA_WRITE" - Data writes. Example: CloudSQL Users create 531 // "DATA_READ" - Data reads. Example: CloudSQL Users list 532 LogType string `json:"logType,omitempty"` 533 // ForceSendFields is a list of field names (e.g. "ExemptedMembers") to 534 // unconditionally include in API requests. By default, fields with empty or 535 // default values are omitted from API requests. See 536 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 537 // details. 538 ForceSendFields []string `json:"-"` 539 // NullFields is a list of field names (e.g. "ExemptedMembers") to include in 540 // API requests with the JSON null value. By default, fields with empty values 541 // are omitted from API requests. See 542 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 543 NullFields []string `json:"-"` 544 } 545 546 func (s *GoogleIamV1AuditLogConfig) MarshalJSON() ([]byte, error) { 547 type NoMethod GoogleIamV1AuditLogConfig 548 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 549 } 550 551 // GoogleIamV1Binding: Associates `members`, or principals, with a `role`. 552 type GoogleIamV1Binding struct { 553 // Condition: The condition that is associated with this binding. If the 554 // condition evaluates to `true`, then this binding applies to the current 555 // request. If the condition evaluates to `false`, then this binding does not 556 // apply to the current request. However, a different role binding might grant 557 // the same role to one or more of the principals in this binding. To learn 558 // which resources support conditions in their IAM policies, see the IAM 559 // documentation 560 // (https://cloud.google.com/iam/help/conditions/resource-policies). 561 Condition *GoogleTypeExpr `json:"condition,omitempty"` 562 // Members: Specifies the principals requesting access for a Google Cloud 563 // resource. `members` can have the following values: * `allUsers`: A special 564 // identifier that represents anyone who is on the internet; with or without a 565 // Google account. * `allAuthenticatedUsers`: A special identifier that 566 // represents anyone who is authenticated with a Google account or a service 567 // account. Does not include identities that come from external identity 568 // providers (IdPs) through identity federation. * `user:{emailid}`: An email 569 // address that represents a specific Google account. For example, 570 // `alice@example.com` . * `serviceAccount:{emailid}`: An email address that 571 // represents a Google service account. For example, 572 // `my-other-app@appspot.gserviceaccount.com`. * 573 // `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An 574 // identifier for a Kubernetes service account 575 // (https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). 576 // For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * 577 // `group:{emailid}`: An email address that represents a Google group. For 578 // example, `admins@example.com`. * `domain:{domain}`: The G Suite domain 579 // (primary) that represents all the users of that domain. For example, 580 // `google.com` or `example.com`. * 581 // `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/sub 582 // ject/{subject_attribute_value}`: A single identity in a workforce identity 583 // pool. * 584 // `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/ 585 // group/{group_id}`: All workforce identities in a group. * 586 // `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/ 587 // attribute.{attribute_name}/{attribute_value}`: All workforce identities with 588 // a specific attribute value. * 589 // `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/ 590 // *`: All identities in a workforce identity pool. * 591 // `principal://iam.googleapis.com/projects/{project_number}/locations/global/wo 592 // rkloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single 593 // identity in a workload identity pool. * 594 // `principalSet://iam.googleapis.com/projects/{project_number}/locations/global 595 // /workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool 596 // group. * 597 // `principalSet://iam.googleapis.com/projects/{project_number}/locations/global 598 // /workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value} 599 // `: All identities in a workload identity pool with a certain attribute. * 600 // `principalSet://iam.googleapis.com/projects/{project_number}/locations/global 601 // /workloadIdentityPools/{pool_id}/*`: All identities in a workload identity 602 // pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus 603 // unique identifier) representing a user that has been recently deleted. For 604 // example, `alice@example.com?uid=123456789012345678901`. If the user is 605 // recovered, this value reverts to `user:{emailid}` and the recovered user 606 // retains the role in the binding. * 607 // `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus 608 // unique identifier) representing a service account that has been recently 609 // deleted. For example, 610 // `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the 611 // service account is undeleted, this value reverts to 612 // `serviceAccount:{emailid}` and the undeleted service account retains the 613 // role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email 614 // address (plus unique identifier) representing a Google group that has been 615 // recently deleted. For example, 616 // `admins@example.com?uid=123456789012345678901`. If the group is recovered, 617 // this value reverts to `group:{emailid}` and the recovered group retains the 618 // role in the binding. * 619 // `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool 620 // _id}/subject/{subject_attribute_value}`: Deleted single identity in a 621 // workforce identity pool. For example, 622 // `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-po 623 // ol-id/subject/my-subject-attribute-value`. 624 Members []string `json:"members,omitempty"` 625 // Role: Role that is assigned to the list of `members`, or principals. For 626 // example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview 627 // of the IAM roles and permissions, see the IAM documentation 628 // (https://cloud.google.com/iam/docs/roles-overview). For a list of the 629 // available pre-defined roles, see here 630 // (https://cloud.google.com/iam/docs/understanding-roles). 631 Role string `json:"role,omitempty"` 632 // ForceSendFields is a list of field names (e.g. "Condition") to 633 // unconditionally include in API requests. By default, fields with empty or 634 // default values are omitted from API requests. See 635 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 636 // details. 637 ForceSendFields []string `json:"-"` 638 // NullFields is a list of field names (e.g. "Condition") to include in API 639 // requests with the JSON null value. By default, fields with empty values are 640 // omitted from API requests. See 641 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 642 NullFields []string `json:"-"` 643 } 644 645 func (s *GoogleIamV1Binding) MarshalJSON() ([]byte, error) { 646 type NoMethod GoogleIamV1Binding 647 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 648 } 649 650 // GoogleIamV1Policy: An Identity and Access Management (IAM) policy, which 651 // specifies access controls for Google Cloud resources. A `Policy` is a 652 // collection of `bindings`. A `binding` binds one or more `members`, or 653 // principals, to a single `role`. Principals can be user accounts, service 654 // accounts, Google groups, and domains (such as G Suite). A `role` is a named 655 // list of permissions; each `role` can be an IAM predefined role or a 656 // user-created custom role. For some types of Google Cloud resources, a 657 // `binding` can also specify a `condition`, which is a logical expression that 658 // allows access to a resource only if the expression evaluates to `true`. A 659 // condition can add constraints based on attributes of the request, the 660 // resource, or both. To learn which resources support conditions in their IAM 661 // policies, see the IAM documentation 662 // (https://cloud.google.com/iam/help/conditions/resource-policies). **JSON 663 // example:** ``` { "bindings": [ { "role": 664 // "roles/resourcemanager.organizationAdmin", "members": [ 665 // "user:mike@example.com", "group:admins@example.com", "domain:google.com", 666 // "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": 667 // "roles/resourcemanager.organizationViewer", "members": [ 668 // "user:eve@example.com" ], "condition": { "title": "expirable access", 669 // "description": "Does not grant access after Sep 2020", "expression": 670 // "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": 671 // "BwWWja0YfJA=", "version": 3 } ``` **YAML example:** ``` bindings: - 672 // members: - user:mike@example.com - group:admins@example.com - 673 // domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com 674 // role: roles/resourcemanager.organizationAdmin - members: - 675 // user:eve@example.com role: roles/resourcemanager.organizationViewer 676 // condition: title: expirable access description: Does not grant access after 677 // Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') 678 // etag: BwWWja0YfJA= version: 3 ``` For a description of IAM and its features, 679 // see the IAM documentation (https://cloud.google.com/iam/docs/). 680 type GoogleIamV1Policy struct { 681 // AuditConfigs: Specifies cloud audit logging configuration for this policy. 682 AuditConfigs []*GoogleIamV1AuditConfig `json:"auditConfigs,omitempty"` 683 // Bindings: Associates a list of `members`, or principals, with a `role`. 684 // Optionally, may specify a `condition` that determines how and when the 685 // `bindings` are applied. Each of the `bindings` must contain at least one 686 // principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; 687 // up to 250 of these principals can be Google groups. Each occurrence of a 688 // principal counts towards these limits. For example, if the `bindings` grant 689 // 50 different roles to `user:alice@example.com`, and not to any other 690 // principal, then you can add another 1,450 principals to the `bindings` in 691 // the `Policy`. 692 Bindings []*GoogleIamV1Binding `json:"bindings,omitempty"` 693 // Etag: `etag` is used for optimistic concurrency control as a way to help 694 // prevent simultaneous updates of a policy from overwriting each other. It is 695 // strongly suggested that systems make use of the `etag` in the 696 // read-modify-write cycle to perform policy updates in order to avoid race 697 // conditions: An `etag` is returned in the response to `getIamPolicy`, and 698 // systems are expected to put that etag in the request to `setIamPolicy` to 699 // ensure that their change will be applied to the same version of the policy. 700 // **Important:** If you use IAM Conditions, you must include the `etag` field 701 // whenever you call `setIamPolicy`. If you omit this field, then IAM allows 702 // you to overwrite a version `3` policy with a version `1` policy, and all of 703 // the conditions in the version `3` policy are lost. 704 Etag string `json:"etag,omitempty"` 705 // Version: Specifies the format of the policy. Valid values are `0`, `1`, and 706 // `3`. Requests that specify an invalid value are rejected. Any operation that 707 // affects conditional role bindings must specify version `3`. This requirement 708 // applies to the following operations: * Getting a policy that includes a 709 // conditional role binding * Adding a conditional role binding to a policy * 710 // Changing a conditional role binding in a policy * Removing any role binding, 711 // with or without a condition, from a policy that includes conditions 712 // **Important:** If you use IAM Conditions, you must include the `etag` field 713 // whenever you call `setIamPolicy`. If you omit this field, then IAM allows 714 // you to overwrite a version `3` policy with a version `1` policy, and all of 715 // the conditions in the version `3` policy are lost. If a policy does not 716 // include any conditions, operations on that policy may specify any valid 717 // version or leave the field unset. To learn which resources support 718 // conditions in their IAM policies, see the IAM documentation 719 // (https://cloud.google.com/iam/help/conditions/resource-policies). 720 Version int64 `json:"version,omitempty"` 721 // ForceSendFields is a list of field names (e.g. "AuditConfigs") to 722 // unconditionally include in API requests. By default, fields with empty or 723 // default values are omitted from API requests. See 724 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 725 // details. 726 ForceSendFields []string `json:"-"` 727 // NullFields is a list of field names (e.g. "AuditConfigs") to include in API 728 // requests with the JSON null value. By default, fields with empty values are 729 // omitted from API requests. See 730 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 731 NullFields []string `json:"-"` 732 } 733 734 func (s *GoogleIamV1Policy) MarshalJSON() ([]byte, error) { 735 type NoMethod GoogleIamV1Policy 736 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 737 } 738 739 // GoogleTypeExpr: Represents a textual expression in the Common Expression 740 // Language (CEL) syntax. CEL is a C-like expression language. The syntax and 741 // semantics of CEL are documented at https://github.com/google/cel-spec. 742 // Example (Comparison): title: "Summary size limit" description: "Determines 743 // if a summary is less than 100 chars" expression: "document.summary.size() < 744 // 100" Example (Equality): title: "Requestor is owner" description: 745 // "Determines if requestor is the document owner" expression: "document.owner 746 // == request.auth.claims.email" Example (Logic): title: "Public documents" 747 // description: "Determine whether the document should be publicly visible" 748 // expression: "document.type != 'private' && document.type != 'internal'" 749 // Example (Data Manipulation): title: "Notification string" description: 750 // "Create a notification string with a timestamp." expression: "'New message 751 // received at ' + string(document.create_time)" The exact variables and 752 // functions that may be referenced within an expression are determined by the 753 // service that evaluates it. See the service documentation for additional 754 // information. 755 type GoogleTypeExpr struct { 756 // Description: Optional. Description of the expression. This is a longer text 757 // which describes the expression, e.g. when hovered over it in a UI. 758 Description string `json:"description,omitempty"` 759 // Expression: Textual representation of an expression in Common Expression 760 // Language syntax. 761 Expression string `json:"expression,omitempty"` 762 // Location: Optional. String indicating the location of the expression for 763 // error reporting, e.g. a file name and a position in the file. 764 Location string `json:"location,omitempty"` 765 // Title: Optional. Title for the expression, i.e. a short string describing 766 // its purpose. This can be used e.g. in UIs which allow to enter the 767 // expression. 768 Title string `json:"title,omitempty"` 769 // ForceSendFields is a list of field names (e.g. "Description") to 770 // unconditionally include in API requests. By default, fields with empty or 771 // default values are omitted from API requests. See 772 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 773 // details. 774 ForceSendFields []string `json:"-"` 775 // NullFields is a list of field names (e.g. "Description") to include in API 776 // requests with the JSON null value. By default, fields with empty values are 777 // omitted from API requests. See 778 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 779 NullFields []string `json:"-"` 780 } 781 782 func (s *GoogleTypeExpr) MarshalJSON() ([]byte, error) { 783 type NoMethod GoogleTypeExpr 784 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 785 } 786 787 type IamTroubleshootCall struct { 788 s *Service 789 googlecloudpolicytroubleshooterv1betatroubleshootiampolicyrequest *GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyRequest 790 urlParams_ gensupport.URLParams 791 ctx_ context.Context 792 header_ http.Header 793 } 794 795 // Troubleshoot: Checks whether a member has a specific permission for a 796 // specific resource, and explains why the member does or does not have that 797 // permission. 798 func (r *IamService) Troubleshoot(googlecloudpolicytroubleshooterv1betatroubleshootiampolicyrequest *GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyRequest) *IamTroubleshootCall { 799 c := &IamTroubleshootCall{s: r.s, urlParams_: make(gensupport.URLParams)} 800 c.googlecloudpolicytroubleshooterv1betatroubleshootiampolicyrequest = googlecloudpolicytroubleshooterv1betatroubleshootiampolicyrequest 801 return c 802 } 803 804 // Fields allows partial responses to be retrieved. See 805 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 806 // details. 807 func (c *IamTroubleshootCall) Fields(s ...googleapi.Field) *IamTroubleshootCall { 808 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 809 return c 810 } 811 812 // Context sets the context to be used in this call's Do method. 813 func (c *IamTroubleshootCall) Context(ctx context.Context) *IamTroubleshootCall { 814 c.ctx_ = ctx 815 return c 816 } 817 818 // Header returns a http.Header that can be modified by the caller to add 819 // headers to the request. 820 func (c *IamTroubleshootCall) Header() http.Header { 821 if c.header_ == nil { 822 c.header_ = make(http.Header) 823 } 824 return c.header_ 825 } 826 827 func (c *IamTroubleshootCall) doRequest(alt string) (*http.Response, error) { 828 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 829 var body io.Reader = nil 830 body, err := googleapi.WithoutDataWrapper.JSONReader(c.googlecloudpolicytroubleshooterv1betatroubleshootiampolicyrequest) 831 if err != nil { 832 return nil, err 833 } 834 c.urlParams_.Set("alt", alt) 835 c.urlParams_.Set("prettyPrint", "false") 836 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/iam:troubleshoot") 837 urls += "?" + c.urlParams_.Encode() 838 req, err := http.NewRequest("POST", urls, body) 839 if err != nil { 840 return nil, err 841 } 842 req.Header = reqHeaders 843 return gensupport.SendRequest(c.ctx_, c.s.client, req) 844 } 845 846 // Do executes the "policytroubleshooter.iam.troubleshoot" call. 847 // Any non-2xx status code is an error. Response headers are in either 848 // *GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyResponse.ServerRes 849 // ponse.Header or (if a response was returned at all) in 850 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 851 // whether the returned error was because http.StatusNotModified was returned. 852 func (c *IamTroubleshootCall) Do(opts ...googleapi.CallOption) (*GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyResponse, error) { 853 gensupport.SetOptions(c.urlParams_, opts...) 854 res, err := c.doRequest("json") 855 if res != nil && res.StatusCode == http.StatusNotModified { 856 if res.Body != nil { 857 res.Body.Close() 858 } 859 return nil, gensupport.WrapError(&googleapi.Error{ 860 Code: res.StatusCode, 861 Header: res.Header, 862 }) 863 } 864 if err != nil { 865 return nil, err 866 } 867 defer googleapi.CloseBody(res) 868 if err := googleapi.CheckResponse(res); err != nil { 869 return nil, gensupport.WrapError(err) 870 } 871 ret := &GoogleCloudPolicytroubleshooterV1betaTroubleshootIamPolicyResponse{ 872 ServerResponse: googleapi.ServerResponse{ 873 Header: res.Header, 874 HTTPStatusCode: res.StatusCode, 875 }, 876 } 877 target := &ret 878 if err := gensupport.DecodeResponse(target, res); err != nil { 879 return nil, err 880 } 881 return ret, nil 882 } 883